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

Go to the SVN repository for this file.

1 /* $Id: reader_pubseq.cpp 101122 2023-11-01 22:41:46Z vasilche $
2 * ===========================================================================
3 * PUBLIC DOMAIN NOTICE
4 * National Center for Biotechnology Information
5 *
6 * This software/database is a "United States Government Work" under the
7 * terms of the United States Copyright Act. It was written as part of
8 * the author's official duties as a United States Government employee and
9 * thus cannot be copyrighted. This software/database is freely available
10 * to the public for use. The National Library of Medicine and the U.S.
11 * Government have not placed any restriction on its use or reproduction.
12 *
13 * Although all reasonable efforts have been taken to ensure the accuracy
14 * and reliability of the software and data, the NLM and the U.S.
15 * Government do not and cannot warrant the performance or results that
16 * may be obtained by using this software or data. The NLM and the U.S.
17 * Government disclaim all warranties, express or implied, including
18 * warranties of performance, merchantability or fitness for any particular
19 * purpose.
20 *
21 * Please cite the author in any work or product based on this material.
22 * ===========================================================================
23 *
24 * Author: Anton Butanaev, Eugene Vasilchenko
25 *
26 * File Description: Data reader from Pubseq_OS
27 *
28 */
29 
30 #include <ncbi_pch.hpp>
31 #include <corelib/ncbi_param.hpp>
35 #include <objtools/data_loaders/genbank/readers.hpp> // for entry point
38 #include <objtools/error_codes.hpp>
39 
41 #include <objmgr/impl/tse_info.hpp>
43 
44 #include <dbapi/driver/types.hpp>
47 #include <dbapi/driver/drivers.hpp>
49 
54 
55 #include <corelib/ncbicntr.hpp>
58 #include <corelib/rwstream.hpp>
59 
60 #include <serial/objistrasnb.hpp>
61 #include <serial/objostrasn.hpp>
62 #include <serial/serial.hpp>
63 
64 #include <util/compress/zlib.hpp>
65 
66 #include <corelib/ncbi_cookies.hpp>
67 
68 #define DEFAULT_DB_SERVER "PUBSEQ_OS_PUBLIC_GI64"
69 #define DEFAULT_DB_USER "anyone"
70 #define DEFAULT_DB_PASSWORD "allowed"
71 #define DEFAULT_DB_DRIVER "ftds;ctlib"
72 #define DEFAULT_NUM_CONN 2
73 #define MAX_MT_CONN 5
74 #define DEFAULT_ALLOW_GZIP true
75 #define DEFAULT_EXCL_WGS_MASTER true
76 
77 #define NCBI_USE_ERRCODE_X Objtools_Rd_Pubseq
78 
81 
82 NCBI_PARAM_DECL(int, GENBANK, PUBSEQOS_DEBUG);
83 NCBI_PARAM_DEF_EX(int, GENBANK, PUBSEQOS_DEBUG, 0,
84  eParam_NoThread, GENBANK_PUBSEQOS_DEBUG);
85 
87 {
88  static CSafeStatic<NCBI_PARAM_TYPE(GENBANK, PUBSEQOS_DEBUG)> s_Value;
89  return s_Value->Get();
90 }
91 
92 #define RPC_GET_ASN "id_get_asn"
93 #define RPC_GET_BLOB_INFO "id_get_blob_prop"
94 
95 enum {
97 };
98 
99 
100 static void sx_SetIntId(CDB_RPCCmd& cmd, const char* param, TIntId id)
101 {
102 #ifdef NCBI_INT8_GI
103  if ( Int4(id) != id ) {
104  // do not fit in Int4
105  CDB_BigInt idIn(id);
106  cmd.SetParam(param, &idIn);
107  return;
108  }
109 #endif
110  CDB_Int idIn(static_cast<Int4>(id));
111  cmd.SetParam(param, &idIn);
112 }
113 
114 
115 static TIntId sx_GetIntId(CDB_Result& dbr, int pos)
116 {
117  CDB_BigInt idGot;
118  dbr.GetItem(&idGot);
119  Int8 id = idGot.Value();
120 #ifndef NCBI_INT8_GI
121  if ( TIntId(id) != id ) {
122  NCBI_THROW_FMT(CLoaderException, eOtherError,
123  dbr.ItemName(pos) << " value overflow: " << id);
124  }
125  return TIntId(id);
126 #else
127  return id;
128 #endif
129 }
130 
131 
134  : zip_type(0), blob_state(0), blob_version(0)
135  {
136  }
137 
139  int zip_type;
142 };
143 
144 
145 CPubseqReader::CPubseqReader(int max_connections,
146  const string& server,
147  const string& user,
148  const string& pswd,
149  const string& dbapi_driver)
150  : m_Server(server) , m_User(user), m_Password(pswd),
151  m_DbapiDriver(dbapi_driver),
152  m_Context(nullptr),
153  m_AllowGzip(DEFAULT_ALLOW_GZIP),
154  m_ExclWGSMaster(DEFAULT_EXCL_WGS_MASTER),
155  m_SetCubbyUser(false)
156 {
157  LOG_POST_X_ONCE(1, "This app is using OM++ PubSeqOS reader which is being phased out. Please switch to using ID2 or PSG.");
158  if ( m_Server.empty() ) {
160  }
161  if ( m_User.empty() ) {
163  }
164  if ( m_Password.empty() ) {
166  }
167  if ( m_DbapiDriver.empty() ) {
169  }
170 
171  SetMaximumConnections(max_connections, DEFAULT_NUM_CONN);
172 }
173 
174 
176  const string& driver_name)
177  : m_Context(nullptr),
178  m_AllowGzip(DEFAULT_ALLOW_GZIP),
179  m_ExclWGSMaster(DEFAULT_EXCL_WGS_MASTER),
180  m_SetCubbyUser(false)
181 {
182  LOG_POST_X_ONCE(1, "This app is using OM++ PubSeqOS reader which is being phased out. Please switch to using ID2 or PSG.");
183  CConfig conf(params);
184  m_Server = conf.GetString(
185  driver_name,
189  m_User = conf.GetString(
190  driver_name,
194  m_Password = conf.GetString(
195  driver_name,
199  m_DbapiDriver = conf.GetString(
200  driver_name,
204  m_AllowGzip = conf.GetBool(
205  driver_name,
209  m_ExclWGSMaster = conf.GetBool(
210  driver_name,
214  /*
215  bool set_cubby_user = conf.GetBool(
216  driver_name,
217  NCBI_GBLOADER_READER_PUBSEQ_PARAM_SET_CUBBY_USER,
218  CConfig::eErr_NoThrow,
219  false);
220  if ( set_cubby_user ) {
221  SetIncludeHUP(set_cubby_user);
222  }
223  */
224  CReader::InitParams(conf, driver_name, DEFAULT_NUM_CONN);
225 }
226 
227 
229 {
230  delete m_Context.exchange(nullptr);
231 }
232 
233 
235 {
236 #if defined(NCBI_THREADS)
237  return MAX_MT_CONN;
238 #else
239  return 1;
240 #endif
241 }
242 
243 
245 {
246  _ASSERT(!m_Connections.count(conn));
248 }
249 
250 
252 {
254 }
255 
256 
258 {
259  _ASSERT(m_Connections.count(conn));
261  if ( stream ) {
262  x_ReportDisconnect("CPubseqReader", "PubSeqOS", conn, failed);
263  stream.reset();
264  }
265 }
266 
267 
269 {
270  _ASSERT(m_Connections.count(conn));
272  if ( stream.get() ) {
273  return stream.get();
274  }
276  return m_Connections[conn].get();
277 }
278 
279 
280 namespace {
281  class CPubseqValidator : public IConnValidator
282  {
283  public:
284  CPubseqValidator(bool allow_gzip, bool excl_wgs_master)
285  : m_AllowGzip(allow_gzip),
286  m_ExclWGSMaster(excl_wgs_master)
287  {
288  }
289 
290  virtual EConnStatus Validate(CDB_Connection& conn) {
291  if ( m_AllowGzip ) {
293  (conn.LangCmd("set accept gzip"));
294  cmd->Send();
295  cmd->DumpResults();
296  }
297  if ( m_ExclWGSMaster ) {
299  (conn.LangCmd("set exclude_wgs_master on"));
300  cmd->Send();
301  cmd->DumpResults();
302  }
303  return eValidConn;
304  }
305 
306  virtual string GetName(void) const {
307  return "CPubseqValidator";
308  }
309 
310  private:
311  bool m_AllowGzip, m_ExclWGSMaster;
312  };
313 
314  I_BaseCmd* x_SendRequest2(const CBlob_id& blob_id,
315  CDB_Connection* db_conn,
316  const char* rpc)
317  {
318  string str = rpc;
319  str += " ";
320  if ( CPubseqReader::IsAnnotSat(blob_id.GetSat()) ) {
322  str += ",";
323  str += NStr::NumericToString(blob_id.GetSat());
324  str += ",";
326  }
327  else {
328  str += NStr::NumericToString(blob_id.GetSatKey());
329  str += ",";
330  str += NStr::NumericToString(blob_id.GetSat());
331  str += ",";
332  str += NStr::NumericToString(blob_id.GetSubSat());
333  }
334  AutoPtr<I_BaseCmd> cmd(db_conn->LangCmd(str));
335  cmd->Send();
336  return cmd.release();
337  }
338 
339 
340  bool sx_FetchNextItem(CDB_Result& result, const CTempString& name)
341  {
342  while ( result.Fetch() ) {
343  for ( unsigned pos = 0; pos < result.NofItems(); ++pos ) {
344  if ( result.ItemName(pos) == name ) {
345  return true;
346  }
347  result.SkipItem();
348  }
349  }
350  return false;
351  }
352 
353  class CDB_Result_Reader : public CObject, public IReader
354  {
355  public:
357  : m_DB_Result(db_result)
358  {
359  }
360 
361  ERW_Result Read(void* buf,
362  size_t count,
363  size_t* bytes_read)
364  {
365  if ( !count ) {
366  if ( bytes_read ) {
367  *bytes_read = 0;
368  }
369  return eRW_Success;
370  }
371  size_t ret;
372  while ( (ret = m_DB_Result->ReadItem(buf, count)) == 0 ) {
373  if ( !sx_FetchNextItem(*m_DB_Result, "asn1") ) {
374  break;
375  }
376  }
377  if ( bytes_read ) {
378  *bytes_read = ret;
379  }
380  return ret? eRW_Success: eRW_Eof;
381  }
382  ERW_Result PendingCount(size_t* /*count*/)
383  {
384  return eRW_NotImplemented;
385  }
386 
387  private:
389  };
390 }
391 
392 
394 {
395  auto context = m_Context.load(memory_order_acquire);
396  if ( !context ) {
397  DEFINE_STATIC_FAST_MUTEX(s_Mutex);
398  CFastMutexGuard guard(s_Mutex);
399  context = m_Context.load(memory_order_acquire);
400  if ( !context ) {
401  DBLB_INSTALL_DEFAULT_EX(eIfSet_KeepSilently);
402  C_DriverMgr drvMgr;
403  map<string,string> args;
404  args["packet"]="3584"; // 7*512
405  args["version"]="125"; // for correct connection to OpenServer
406  vector<string> driver_list;
407  NStr::Split(m_DbapiDriver, ";", driver_list);
408  size_t driver_count = driver_list.size();
409  vector<string> errmsg(driver_count);
410  for ( size_t i = 0; i < driver_count; ++i ) {
411  try {
412  context = drvMgr.GetDriverContext(driver_list[i],
413  &errmsg[i], &args);
414  if ( context ) {
415  break;
416  }
417  }
418  catch ( exception& exc ) {
419  errmsg[i] = exc.what();
420  }
421  }
422  if ( !context ) {
423  for ( size_t i = 0; i < driver_count; ++i ) {
424  ERR_POST_X(2, "Failed to create dbapi context with driver '"
425  <<driver_list[i]<<"': "<<errmsg[i]);
426  }
427  NCBI_THROW(CLoaderException, eNoConnection,
428  "Cannot create dbapi context with driver '"+
429  m_DbapiDriver+"'");
430  }
431  }
432  m_Context.store(context, memory_order_release);
433  }
434 
435  _TRACE("CPubseqReader::NewConnection("<<m_Server<<")");
436  CPubseqValidator validator(m_AllowGzip, m_ExclWGSMaster);
438  (context->ConnectValidated(m_Server, m_User, m_Password, validator));
439 
440  if ( !conn.get() ) {
441  NCBI_THROW(CLoaderException, eConnectionFailed, "connection failed");
442  }
443 
444  if ( m_SetCubbyUser ) {
445  // Using a formal parameter is typically better practice, but
446  // likely won't work here (a custom Open Server).
447  string encoded = NStr::SQLEncode(CSystemInfo::GetUserName(),
449  AutoPtr<CDB_LangCmd> cmd(conn->LangCmd("set cubby_user " + encoded));
450  cmd->Send();
451  cmd->DumpResults();
452  }
453 
454  if ( GetDebugLevel() >= 2 ) {
455  CDebugPrinter s(conn_, "CPubseqReader");
456  s << "Connected to " << conn->ServerName();
457  }
458 
459  m_Connections[conn_].reset(conn.release());
460 }
461 
462 
463 // LoadSeq_idGi, LoadSeq_idSeq_ids, and LoadSeq_idBlob_ids
464 // are implemented here and call the same function because
465 // PubSeqOS has one RPC call that may suite all needs
466 // LoadSeq_idSeq_ids works like this only when Seq-id is not gi
467 // To prevent deadlocks these functions lock Seq-ids before Blob-ids.
468 
470  const CSeq_id_Handle& seq_id)
471 {
472  CLoadLockGi lock(result, seq_id);
473  if ( lock.IsLoadedGi() ) {
474  return true;
475  }
476  return LoadSeq_idInfo(result, seq_id, 0);
477 }
478 
479 
481  const CSeq_id_Handle& seq_id)
482 {
483  CLoadLockSeqIds lock(result, seq_id);
484  if ( lock.IsLoaded() ) {
485  return true;
486  }
487 
488  if ( seq_id.Which() == CSeq_id::e_Gi ) {
489  return LoadGiSeq_ids(result, seq_id);
490  }
491 
492  CLoadLockGi gi_lock(result, seq_id);
493  if ( !gi_lock.IsLoadedGi() ) {
494  m_Dispatcher->LoadSeq_idGi(result, seq_id);
495  if ( lock.IsLoaded() ) {
496  return true;
497  }
498  if ( !gi_lock.IsLoadedGi() ) {
499  return false;
500  }
501  }
502  TSequenceGi data = gi_lock.GetGi();
503  TGi gi = gi_lock.GetGi(data);
504  if ( gi == ZERO_GI ) {
505  // no gi -> no Seq-ids
506  SetAndSaveNoSeq_idSeq_ids(result, seq_id, 0);
507  return true;
508  }
509 
511  CLoadLockSeqIds gi_ids(result, gi_handle);
513  if ( !gi_ids.IsLoaded() ) {
514  return false;
515  }
516 
517  // copy Seq-id list from gi to original seq-id
518  SetAndSaveSeq_idSeq_ids(result, seq_id, gi_ids);
519  return true;
520 }
521 
522 
524  const CSeq_id_Handle& seq_id,
525  const SAnnotSelector* sel)
526 {
527  CLoadLockBlobIds blob_ids(result, seq_id, sel);
528  if ( blob_ids.IsLoaded() ) {
529  return true;
530  }
531 
532  CLoadLockSeqIds seq_ids(result, seq_id, eAlreadyLoaded);
533  if ( seq_ids ) {
536  // no such seq-id
538  return true;
539  }
540  }
541 
542  if ( !sel || !sel->IsIncludedAnyNamedAnnotAccession() ) {
543  // no named annot accessions
544  return LoadSeq_idInfo(result, seq_id, 0);
545  }
546 
547  if ( sel->IsIncludedNamedAnnotAccession("NA*") ) {
548  // all named annot accessions
549  return LoadSeq_idInfo(result, seq_id, sel);
550  }
551 
552  // part of named annot accessions
553  SAnnotSelector all_sel;
554  all_sel.IncludeNamedAnnotAccession("NA*");
555  if ( !LoadSeq_idInfo(result, seq_id, &all_sel) ) {
556  return false;
557  }
558  CLoadLockBlobIds all_blob_ids(result, seq_id, &all_sel);
559  _ASSERT(all_blob_ids.IsLoaded());
560  // filter accessions
561  SetAndSaveSeq_idBlob_ids(result, seq_id, sel, blob_ids, all_blob_ids);
562  return true;
563 }
564 
565 
567  const CSeq_id_Handle& seq_id)
568 {
569  CLoadLockAcc lock(result, seq_id);
570  if ( lock.IsLoadedAccVer() ) {
571  return true;
572  }
573 
574  if ( seq_id.IsGi() ) {
575  _ASSERT(seq_id.Which() == CSeq_id::e_Gi);
576  TGi gi = seq_id.GetGi();
577  if (gi != ZERO_GI) {
578  _TRACE("ResolveGi to Acc: " << gi);
579 
580  CConn conn(result, this);
581  {{
582  CDB_Connection* db_conn = x_GetConnection(conn);
583 
584  AutoPtr<CDB_RPCCmd> cmd(db_conn->RPC("id_get_accn_ver_by_gi"));
586  cmd->Send();
587 
588  //bool not_found = false;
589  while ( cmd->HasMoreResults() ) {
590  AutoPtr<CDB_Result> dbr(cmd->Result());
591  if ( !dbr.get() ) {
592  continue;
593  }
594 
595  if ( dbr->ResultType() == eDB_StatusResult ) {
596  dbr->Fetch();
597  CDB_Int v;
598  dbr->GetItem(&v);
599  int status = v.Value();
600  if ( status == 100 ) {
601  // gi does not exist
602  // but there no way to report it except by
603  // trying to load all Seq-ids later
604  //not_found = true;
605  }
606  }
607  else if ( dbr->ResultType() == eDB_RowResult &&
608  sx_FetchNextItem(*dbr, "accver") ) {
609  CDB_VarChar accVerGot;
610  dbr->GetItem(&accVerGot);
611  try {
612  TSequenceAcc data;
613  data.acc_ver =
614  CSeq_id_Handle::GetHandle(accVerGot.Value());
615  data.sequence_found = true;
616  SetAndSaveSeq_idAccVer(result, seq_id, data);
617  while ( dbr->Fetch() )
618  ;
619  cmd->DumpResults();
620  break;
621  }
622  catch ( exception& /*exc*/ ) {
623  /*
624  ERR_POST_X(7,
625  "CPubseqReader: bad accver data: "<<
626  " gi "<<gi<<" -> "<<accVerGot.Value()<<
627  ": "<< exc.GetMsg());
628  */
629  }
630  }
631  while ( dbr->Fetch() )
632  ;
633  }
634  }}
635  conn.Release();
636  }
637  }
638 
639  if ( !lock.IsLoadedAccVer() ) {
641  }
642 
643  return true;
644 }
645 
646 
648  const CSeq_id_Handle& seq_id,
649  const SAnnotSelector* with_named_accs)
650 {
651  // Get gi by seq-id
652  _TRACE("ResolveSeq_id to gi/sat/satkey: " << seq_id.AsString());
653 
654  CDB_VarChar asnIn;
655  {{
656  CNcbiOstrstream oss;
657  if ( seq_id.IsGi() ) {
658  oss << "Seq-id ::= gi " << CProcessor::ConvertGiFromOM(seq_id.GetGi());
659  }
660  else {
661  CObjectOStreamAsn ooss(oss);
662  ooss << *CProcessor::ConvertIdFromOM(seq_id).GetSeqId();
663  }
664  asnIn = CNcbiOstrstreamToString(oss);
665  }}
666 
667  int result_count = 0;
668  TGi named_gi = ZERO_GI;
669  CConn conn(result, this);
670  {{
671  CDB_Connection* db_conn = x_GetConnection(conn);
672 
673  AutoPtr<CDB_RPCCmd> cmd(db_conn->RPC("id_gi_by_seqid_asn"));
674  cmd->SetParam("@asnin", &asnIn);
675  cmd->Send();
676 
677  TBlobIds blob_ids;
678 
679  while(cmd->HasMoreResults()) {
680  AutoPtr<CDB_Result> dbr(cmd->Result());
681  if ( !dbr.get() ) {
682  continue;
683  }
684 
685  if ( dbr->ResultType() != eDB_RowResult) {
686  while ( dbr->Fetch() )
687  ;
688  continue;
689  }
690 
691  while ( dbr->Fetch() ) {
692  TGi gi = ZERO_GI;
693  CDB_Int satGot;
694  CDB_Int sat_keyGot;
695  CDB_Int extFeatGot;
696  CDB_Int namedAnnotsGot;
697 
698  _TRACE("next fetch: " << dbr->NofItems() << " items");
699  ++result_count;
700  for ( unsigned pos = 0; pos < dbr->NofItems(); ++pos ) {
701  const string& name = dbr->ItemName(pos);
702  _TRACE("next item: " << name);
703  if (name == "gi") {
704  gi = GI_FROM(TIntId, sx_GetIntId(*dbr, pos));
705  _TRACE("gi: "<<gi);
707  }
708  else if (name == "sat" ) {
709  dbr->GetItem(&satGot);
710  _TRACE("sat: "<<satGot.Value());
711  }
712  else if(name == "sat_key") {
713  dbr->GetItem(&sat_keyGot);
714  _TRACE("sat_key: "<<sat_keyGot.Value());
715  }
716  else if(name == "extra_feat" || name == "ext_feat") {
717  dbr->GetItem(&extFeatGot);
718 #ifdef _DEBUG
719  if ( extFeatGot.IsNULL() ) {
720  _TRACE("ext_feat = NULL");
721  }
722  else {
723  _TRACE("ext_feat = "<<extFeatGot.Value());
724  }
725 #endif
726  }
727  else if (name == "named_annots" ) {
728  dbr->GetItem(&namedAnnotsGot);
729  _TRACE("named_annots = "<<namedAnnotsGot.Value());
730  if ( namedAnnotsGot.Value() ) {
731  named_gi = gi;
732  }
733  }
734  else {
735  dbr->SkipItem();
736  }
737  }
738 
739  int sat = satGot.Value();
740  int sat_key = sat_keyGot.Value();
741 
742  if ( GetDebugLevel() >= 5 ) {
743  CDebugPrinter s(conn, "CPubseqReader");
744  s << "ResolveSeq_id"
745  "(" << seq_id.AsString() << ")"
746  " gi=" << gi <<
747  " sat=" << sat <<
748  " satkey=" << sat_key <<
749  " extfeat=";
750  if ( extFeatGot.IsNULL() ) {
751  s << "NULL";
752  }
753  else {
754  s << extFeatGot.Value();
755  }
756  }
757 
758  if ( gi == ZERO_GI && !sat && !sat_key ) {
759  // no sequence found
761  }
762  else {
763  // we've got gi, possibly ZERO_GI meaning no GI on sequence
764  TSequenceGi data;
765  data.gi = gi;
766  data.sequence_found = true;
767  SetAndSaveSeq_idGi(result, seq_id, data);
768  }
769 
770  if ( CProcessor::TrySNPSplit() && !IsAnnotSat(sat) ) {
771  // main blob
772  CRef<CBlob_id> blob_id(new CBlob_id);
773  blob_id->SetSat(sat);
774  blob_id->SetSatKey(sat_key);
775  blob_ids.push_back(CBlob_Info(blob_id, fBlobHasAllLocal));
776  if ( !extFeatGot.IsNULL() ) {
778  }
779  }
780  else {
781  // whole blob
782  CRef<CBlob_id> blob_id(new CBlob_id);
783  blob_id->SetSat(sat);
784  blob_id->SetSatKey(sat_key);
785  if ( !extFeatGot.IsNULL() ) {
786  blob_id->SetSubSat(extFeatGot.Value());
787  }
788  blob_ids.push_back(CBlob_Info(blob_id, fBlobHasAllLocal));
789  }
790  }
791  }
792 
793  cmd.reset();
794 
795  if ( with_named_accs && named_gi != ZERO_GI ) {
796  // postponed read of named annot accessions
797  _TRACE("id_get_annot_types "<<named_gi);
798  AutoPtr<CDB_RPCCmd> cmd(db_conn->RPC("id_get_annot_types"));
800  cmd->Send();
801  while(cmd->HasMoreResults()) {
802  AutoPtr<CDB_Result> dbr(cmd->Result());
803  if ( !dbr.get() ) {
804  continue;
805  }
806 
807  if ( dbr->ResultType() != eDB_RowResult) {
808  while ( dbr->Fetch() )
809  ;
810  continue;
811  }
812 
813  while ( dbr->Fetch() ) {
814  TGi gi = ZERO_GI;
815  CDB_Int satGot;
816  CDB_Int satKeyGot;
817  CDB_Int typeGot;
818  CDB_VarChar nameGot;
819  for ( unsigned pos = 0; pos < dbr->NofItems(); ++pos ) {
820  const string& name = dbr->ItemName(pos);
821  _TRACE("next item: " << name);
822  if (name == "gi") {
823  gi = GI_FROM(TIntId, sx_GetIntId(*dbr, pos));
824  _TRACE("ngi: "<<gi);
826  }
827  else if (name == "sat" ) {
828  dbr->GetItem(&satGot);
829  _TRACE("nsat: "<<satGot.Value());
830  }
831  else if(name == "sat_key") {
832  dbr->GetItem(&satKeyGot);
833  _TRACE("nsat_key: "<<satKeyGot.Value());
834  }
835  else if(name == "type") {
836  dbr->GetItem(&typeGot);
837  _TRACE("ntype: "<<typeGot.Value());
838  }
839  else if(name == "name") {
840  dbr->GetItem(&nameGot);
841  _TRACE("nname: "<<nameGot.Value());
842  }
843  else {
844  dbr->SkipItem();
845  }
846  }
847  CRef<CBlob_id> blob_id(new CBlob_id);
848  blob_id->SetSat(satGot.Value());
849  blob_id->SetSatKey(satKeyGot.Value());
852  annot_info->AddNamedAnnotName(nameGot.Value());
853  info.SetAnnotInfo(annot_info);
854  blob_ids.push_back(info);
855  }
856  }
857  }
858 
859  if ( result_count == 0 ) {
861  SetAndSaveNoSeq_idSeq_ids(result, seq_id, 0);
862  SetAndSaveNoSeq_idBlob_ids(result, seq_id, with_named_accs, 0);
863  }
864  else {
865  SetAndSaveSeq_idBlob_ids(result, seq_id, with_named_accs,
866  CFixedBlob_ids(eTakeOwnership, blob_ids));
867  }
868  }}
869 
870  conn.Release();
871  return result_count > 0;
872 }
873 
874 
876  const CSeq_id_Handle& seq_id)
877 {
878  CLoadLockSeqIds load_lock(result, seq_id);
879  if ( load_lock.IsLoaded() ) {
880  return true;
881  }
882  _ASSERT(seq_id.Which() == CSeq_id::e_Gi);
883  TGi gi = seq_id.GetGi();
884  if ( gi == ZERO_GI ) {
885  SetAndSaveNoSeq_idSeq_ids(result, seq_id, 0);
886  return true;
887  }
888 
889  _TRACE("ResolveGi to Seq-ids: " << gi);
890 
891  CConn conn(result, this);
892  {{
893  TSeqIds ids;
894  CDB_Connection* db_conn = x_GetConnection(conn);
895 
896  AutoPtr<CDB_RPCCmd> cmd(db_conn->RPC("id_seqid4gi"));
898  CDB_TinyInt binIn = 1;
899  cmd->SetParam("@bin", &binIn);
900  cmd->Send();
901 
902  int state = 0;
903  bool not_found = false;
904  while ( cmd->HasMoreResults() ) {
905  AutoPtr<CDB_Result> dbr(cmd->Result());
906  if ( !dbr.get() ) {
907  continue;
908  }
909 
910  if ( dbr->ResultType() == eDB_StatusResult ) {
911  while ( dbr->Fetch() ) {
912  CDB_Int v;
913  dbr->GetItem(&v);
914  int status = v.Value();
915  if ( status == 100 ) {
916  // gi does not exist
917  not_found = true;
919  }
920  }
921  if ( not_found ) {
922  cmd->Cancel();
923  break;
924  }
925  }
926  else if ( dbr->ResultType() == eDB_RowResult &&
927  sx_FetchNextItem(*dbr, "seqid") ) {
928  CDB_Result_Reader reader(dbr);
929  CRStream stream(&reader);
930  CObjectIStreamAsnBinary in(stream);
931  CSeq_id id;
932  while ( in.HaveMoreData() ) {
933  in >> id;
935  ids.push_back(CSeq_id_Handle::GetHandle(id));
936  }
937  if ( in.HaveMoreData() ) {
938  ERR_POST_X(4, "CPubseqReader: extra seqid data");
939  }
940  while ( dbr->Fetch() )
941  ;
942  cmd->DumpResults();
943  break;
944  }
945  while ( dbr->Fetch() )
946  ;
947  }
948  if ( ids.empty() && !not_found ) {
949  // artificially add argument Seq-id if empty set was received
950  ids.push_back(seq_id);
951  }
954  }}
955  conn.Release();
956  return true;
957 }
958 
959 
961  const CSeq_id_Handle& seq_id)
962 {
963  CLoadLockHash lock(result, seq_id);
964  if ( lock.IsLoaded() ) {
965  return true;
966  }
967 
968  if ( seq_id.Which() == CSeq_id::e_Gi ) {
969  return LoadGiHash(result, seq_id);
970  }
971 
972  CLoadLockGi gi_lock(result, seq_id);
973  if ( !gi_lock.IsLoadedGi() ) {
974  m_Dispatcher->LoadSeq_idGi(result, seq_id);
975  if ( lock.IsLoaded() ) {
976  return true;
977  }
978  if ( !gi_lock.IsLoadedGi() ) {
979  return false;
980  }
981  }
982  TSequenceGi gi = gi_lock.GetGi();
983  if ( !gi_lock.IsFound(gi) ) {
984  // no sequence
985  result.SetLoadedHash(seq_id, TSequenceHash());
986  return true;
987  }
988  if ( gi_lock.GetGi(gi) == ZERO_GI ) {
989  // no gi -> no hash known
991  hash.sequence_found = true;
992  result.SetLoadedHash(seq_id, hash);
993  return true;
994  }
995 
996  CSeq_id_Handle gi_handle = CSeq_id_Handle::GetGiHandle(gi_lock.GetGi(gi));
997  CLoadLockHash gi_hash(result, gi_handle);
998  m_Dispatcher->LoadSequenceHash(result, gi_handle);
999  if ( !gi_hash.IsLoadedHash() ) {
1000  return false;
1001  }
1002 
1003  // copy Seq-id list from gi to original seq-id
1004  result.SetLoadedHash(seq_id, gi_hash.GetHash());
1005  return true;
1006 }
1007 
1008 
1010  const CSeq_id_Handle& seq_id)
1011 {
1012  CLoadLockSeqIds load_lock(result, seq_id);
1013  if ( load_lock.IsLoaded() ) {
1014  return true;
1015  }
1016  _ASSERT(seq_id.Which() == CSeq_id::e_Gi);
1017  TGi gi = seq_id.GetGi();
1018  if ( gi == ZERO_GI ) {
1019  result.SetLoadedHash(seq_id, TSequenceHash());
1020  return true;
1021  }
1022 
1023  _TRACE("ResolveGi to Hash: " << gi);
1024 
1025  CConn conn(result, this);
1026  {{
1027  TSeqIds ids;
1028  CDB_Connection* db_conn = x_GetConnection(conn);
1029 
1030  AutoPtr<CDB_RPCCmd> cmd(db_conn->RPC("id_gi_class"));
1032  CDB_TinyInt hashIn = 1;
1033  cmd->SetParam("@ver", &hashIn);
1034  cmd->Send();
1035 
1037  while ( cmd->HasMoreResults() ) {
1038  AutoPtr<CDB_Result> dbr(cmd->Result());
1039  if ( !dbr.get() ) {
1040  continue;
1041  }
1042 
1043  if ( dbr->ResultType() == eDB_RowResult &&
1044  sx_FetchNextItem(*dbr, "hash") ) {
1045  CDB_Int v;
1046  dbr->GetItem(&v);
1047  hash.hash = v.Value();
1048  hash.sequence_found = true;
1049  hash.hash_known = true;
1050  }
1051  while ( dbr->Fetch() )
1052  ;
1053  }
1055  }}
1056  conn.Release();
1057  return true;
1058 }
1059 
1060 
1062  const CBlob_id& blob_id)
1063 {
1064  CConn conn(result, this);
1065  {{
1066  CDB_Connection* db_conn = x_GetConnection(conn);
1068  (x_SendRequest2(blob_id, db_conn, RPC_GET_BLOB_INFO));
1070  x_ReceiveData(result, data, blob_id, *cmd, false);
1071  if ( data.dbr ) {
1072  ERR_POST_X(3, "CPubseqReader: unexpected blob data");
1073  }
1074  }}
1075  conn.Release();
1076  if ( !blob_id.IsMainBlob() ) {
1077  result.SetAndSaveBlobState(blob_id, 0);
1078  }
1079 }
1080 
1081 
1083  const CBlob_id& blob_id)
1084 {
1085  try {
1086  CConn conn(result, this);
1087  {{
1088  CDB_Connection* db_conn = x_GetConnection(conn);
1090  (x_SendRequest2(blob_id, db_conn, RPC_GET_BLOB_INFO));
1092  x_ReceiveData(result, data, blob_id, *cmd, false);
1093  if ( data.dbr ) {
1094  ERR_POST_X(5, "CPubseqReader: unexpected blob data");
1095  }
1096  }}
1097  conn.Release();
1098  if ( !blob_id.IsMainBlob() ) {
1099  result.SetAndSaveBlobVersion(blob_id, 0);
1100  }
1101  }
1102  catch ( exception& ) {
1103  if ( !blob_id.IsMainBlob() ) {
1104  result.SetAndSaveBlobVersion(blob_id, 0);
1105  return;
1106  }
1107  throw;
1108  }
1109 }
1110 
1111 
1113  const TBlobId& blob_id,
1114  TChunkId chunk_id)
1115 {
1116  CLoadLockBlob blob(result, blob_id, chunk_id);
1117  if ( blob.IsLoadedChunk() ) {
1118  return;
1119  }
1120  CConn conn(result, this);
1121  {{
1122  CDB_Connection* db_conn = x_GetConnection(conn);
1123  AutoPtr<I_BaseCmd> cmd(x_SendRequest(blob_id, db_conn, RPC_GET_ASN));
1125  x_ReceiveData(result, data, blob_id, *cmd, true);
1126  if ( data.dbr ) {
1127  CDB_Result_Reader reader(data.dbr);
1128  CRStream stream(&reader);
1129  CProcessor::EType processor_type;
1130  if ( blob_id.GetSubSat() == eSubSat_SNP ) {
1131  processor_type = CProcessor::eType_Seq_entry_SNP;
1132  }
1133  else {
1134  processor_type = CProcessor::eType_Seq_entry;
1135  }
1136  if ( data.zip_type & fZipType_gzipped ) {
1137  CCompressionIStream unzip(stream,
1140  m_Dispatcher->GetProcessor(processor_type)
1141  .ProcessStream(result, blob_id, chunk_id, unzip);
1142  }
1143  else {
1144  m_Dispatcher->GetProcessor(processor_type)
1145  .ProcessStream(result, blob_id, chunk_id, stream);
1146  }
1147  char buf[1];
1148  if ( stream.read(buf, 1) && stream.gcount() ) {
1149  ERR_POST_X(6, "CPubseqReader: extra blob data: "<<blob_id);
1150  }
1151  cmd->DumpResults();
1152  }
1153  else {
1154  SetAndSaveNoBlob(result, blob_id, chunk_id, data.blob_state);
1155  }
1156  }}
1157  conn.Release();
1158 }
1159 
1160 
1162  CDB_Connection* db_conn,
1163  const char* rpc)
1164 {
1165  _TRACE("x_SendRequest: "<<blob_id.ToString());
1166  AutoPtr<CDB_RPCCmd> cmd(db_conn->RPC(rpc));
1167  if ( IsAnnotSat(blob_id.GetSat()) ) {
1168  // extract actual GI from sat_key and sub_sat fields
1169  CDB_BigInt idIn(GetExtAnnotGi(blob_id));
1170  cmd->SetParam("@gi", &idIn);
1171  CDB_SmallInt satIn(blob_id.GetSat());
1172  cmd->SetParam("@sat", &satIn);
1173  CDB_Int ext_feat(GetExtAnnotSubSat(blob_id));
1174  cmd->SetParam("@ext_feat", &ext_feat);
1175  }
1176  else {
1177  CDB_SmallInt satIn(blob_id.GetSat());
1178  cmd->SetParam("@sat", &satIn);
1179  CDB_Int satKeyIn(blob_id.GetSatKey());
1180  cmd->SetParam("@sat_key", &satKeyIn);
1181  CDB_Int ext_feat(blob_id.GetSubSat());
1182  cmd->SetParam("@ext_feat", &ext_feat);
1183  }
1184  cmd->Send();
1185  return cmd.release();
1186 }
1187 
1188 
1191  const TBlobId& blob_id,
1192  I_BaseCmd& cmd,
1193  bool force_blob)
1194 {
1195  enum {
1196  kState_dead = 125
1197  };
1198 
1199  // new row
1200  while( !ret.dbr && cmd.HasMoreResults() ) {
1201  _TRACE("next result");
1202  if ( cmd.HasFailed() ) {
1203  break;
1204  }
1205 
1206  AutoPtr<CDB_Result> dbr(cmd.Result());
1207  if ( !dbr.get() ) {
1208  continue;
1209  }
1210 
1211  if ( dbr->ResultType() != eDB_RowResult ) {
1212  while ( dbr->Fetch() )
1213  ;
1214  continue;
1215  }
1216 
1217  while ( !ret.dbr && dbr->Fetch() ) {
1218  _TRACE("next fetch: " << dbr->NofItems() << " items");
1219  for ( unsigned pos = 0; pos < dbr->NofItems(); ++pos ) {
1220  const string& name = dbr->ItemName(pos);
1221  _TRACE("next item: " << name);
1222  if ( name == "confidential" ) {
1223  CDB_Int v;
1224  dbr->GetItem(&v);
1225  _TRACE("confidential: "<<v.Value());
1226  if ( v.Value() ) {
1228  }
1229  }
1230  else if ( name == "suppress" ) {
1231  CDB_Int v;
1232  dbr->GetItem(&v);
1233  _TRACE("suppress: "<<v.Value());
1234  if ( v.Value() & 5 ) { // suppressed(=1) & temporary(=4)
1235  ret.blob_state |= (v.Value() == 4)
1238  }
1239  }
1240  else if ( name == "override" ) {
1241  CDB_Int v;
1242  dbr->GetItem(&v);
1243  _TRACE("withdrawn: "<<v.Value());
1244  if ( v.Value() ) {
1246  }
1247  }
1248  else if ( name == "last_touched_m" ) {
1249  CDB_Int v;
1250  dbr->GetItem(&v);
1251  _TRACE("version: " << v.Value());
1252  ret.blob_version = v.Value();
1253  }
1254  else if ( name == "state" ) {
1255  CDB_Int v;
1256  dbr->GetItem(&v);
1257  _TRACE("state: "<<v.Value());
1258  if ( v.Value() == kState_dead ) {
1260  }
1261  }
1262  else if ( name == "zip_type" ) {
1263  CDB_Int v;
1264  dbr->GetItem(&v);
1265  _TRACE("zip_type: "<<v.Value());
1266  ret.zip_type = v.Value();
1267  }
1268  else if ( name == "asn1" ) {
1269  ret.dbr.reset(dbr.release());
1270  break;
1271  }
1272  else {
1273 #ifdef _DEBUG
1274  AutoPtr<CDB_Object> item(dbr->GetItem(0));
1275  _TRACE("item type: " << item->GetType());
1276  switch ( item->GetType() ) {
1277  case eDB_Int:
1278  case eDB_SmallInt:
1279  case eDB_TinyInt:
1280  {
1281  CDB_Int v;
1282  v.AssignValue(*item);
1283  _TRACE("item value: " << v.Value());
1284  break;
1285  }
1286  case eDB_VarChar:
1287  {
1288  CDB_VarChar v;
1289  v.AssignValue(*item);
1290  _TRACE("item value: " << v.Value());
1291  break;
1292  }
1293  default:
1294  break;
1295  }
1296 #else
1297  dbr->SkipItem();
1298 #endif
1299  }
1300  }
1301  }
1302  }
1303  if ( !ret.dbr && force_blob ) {
1304  // no data
1305  _TRACE("actually no data");
1307  }
1308  result.SetAndSaveBlobState(blob_id, ret.blob_state);
1309  result.SetAndSaveBlobVersion(blob_id, ret.blob_version);
1310 }
1311 
1312 
1313 void CPubseqReader::SetIncludeHUP(bool include_hup, const string& web_cookie)
1314 {
1315  x_SetIncludeHUP(include_hup);
1316  m_SetCubbyUser = include_hup;
1317  if ( !web_cookie.empty() ) {
1318  // link-in corelib classes used by CPubseqReader2
1319  CHttpCookies();
1320  }
1321 }
1322 
1323 
1325 
1327 {
1328  RegisterEntryPoint<objects::CReader>(NCBI_EntryPoint_ReaderPubseqos);
1329 }
1330 
1331 
1332 /// Class factory for Pubseq reader
1333 ///
1334 /// @internal
1335 ///
1337  public CSimpleClassFactoryImpl<objects::CReader,
1338  objects::CPubseqReader>
1339 {
1340 public:
1341  typedef CSimpleClassFactoryImpl<objects::CReader,
1342  objects::CPubseqReader> TParent;
1343 public:
1346 
1348 
1349  objects::CReader*
1350  CreateInstance(const string& driver = kEmptyStr,
1352  NCBI_INTERFACE_VERSION(objects::CReader),
1353  const TPluginManagerParamTree* params = 0) const
1354  {
1355  objects::CReader* drv = 0;
1356  if ( !driver.empty() && driver != m_DriverName ) {
1357  return 0;
1358  }
1359  if (version.Match(NCBI_INTERFACE_VERSION(objects::CReader))
1361  drv = new objects::CPubseqReader(params, driver);
1362  }
1363  return drv;
1364  }
1365 };
1366 
1367 
1371 {
1373  NCBI_EntryPointImpl(info_list, method);
1374 }
1375 
1376 
1380 {
1381  NCBI_EntryPoint_ReaderPubseqos(info_list, method);
1382 }
1383 
1384 
#define static
User-defined methods of the data storage class.
User-defined methods of the data storage class.
#define false
Definition: bool.h:36
TSat GetSat() const
Definition: blob_id.hpp:56
bool IsMainBlob(void) const
Definition: blob_id.hpp:100
TSatKey GetSatKey() const
Definition: blob_id.hpp:64
TSubSat GetSubSat() const
Definition: blob_id.hpp:60
string ToString(void) const
Get string representation of blob id.
Definition: blob_id.cpp:67
ERW_Result PendingCount(size_t *)
Via parameter "count" (which is guaranteed to be supplied non-NULL) return the number of bytes that a...
Definition: asn2asn.cpp:746
ERW_Result Read(void *buf, size_t count, size_t *bytes_read)
Read as many as "count" bytes into a buffer pointed to by the "buf" argument.
Definition: asn2asn.cpp:727
CDB_Result * m_DB_Result
Definition: asn2asn.cpp:751
CDB_Result_Reader(CDB_Result *db_result)
Definition: asn2asn.cpp:723
static TIntId GetExtAnnotGi(const CBlob_id &blob_id)
static void CreateExtAnnotBlob_ids(TBlobIds &blob_ids, TIntId gi, int ext_feat)
static bool IsAnnotSat(int sat)
static int GetExtAnnotSubSat(const CBlob_id &blob_id)
bool IsLoadedAccVer(void) const
bool IsLoadedChunk(void) const
bool IsLoadedGi(void) const
static bool IsFound(const TData &data)
static TGi GetGi(const TData &data)
bool IsLoadedHash(void) const
static int GetHash(const TData &data)
TData::TState GetState(void) const
Data loader exceptions, used by GenBank loader.
CNcbiOstrstreamToString class helps convert CNcbiOstrstream to a string Sample usage:
Definition: ncbistre.hpp:802
CObjectIStreamAsnBinary –.
Definition: objistrasnb.hpp:59
CObjectOStreamAsn –.
Definition: objostrasn.hpp:53
CObject –.
Definition: ncbiobj.hpp:180
static TGi ConvertGiFromOM(TGi gi)
Definition: processor.hpp:139
@ eType_Seq_entry
Definition: processor.hpp:71
@ eType_Seq_entry_SNP
Definition: processor.hpp:72
virtual void ProcessStream(CReaderRequestResult &result, const TBlobId &blob_id, TChunkId chunk_id, CNcbiIstream &stream) const
Definition: processors.cpp:237
static void OffsetGiToOM(TGi &gi)
Definition: processor.hpp:154
static bool TrySNPSplit(void)
Definition: processors.cpp:328
static void OffsetIdToOM(CSeq_id &id)
Definition: processor.hpp:158
static CSeq_id_Handle ConvertIdFromOM(CSeq_id_Handle id)
Definition: processor.hpp:149
Class factory for Pubseq reader.
objects::CReader * CreateInstance(const string &driver=kEmptyStr, CVersionInfo version=NCBI_INTERFACE_VERSION(objects::CReader), const TPluginManagerParamTree *params=0) const
Create instance of TDriver.
CSimpleClassFactoryImpl< objects::CReader, objects::CPubseqReader > TParent
atomic< I_DriverContext * > m_Context
bool LoadGiHash(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
virtual void GetBlobState(CReaderRequestResult &result, const CBlob_id &blob_id) override
virtual ~CPubseqReader() override
virtual void GetBlob(CReaderRequestResult &result, const TBlobId &blob_id, TChunkId chunk_id) override
virtual int GetMaximumConnectionsLimit(void) const override
virtual void x_ConnectAtSlot(TConn conn) override
I_BaseCmd * x_SendRequest(const CBlob_id &blob_id, CDB_Connection *db_conn, const char *rpc)
virtual void x_DisconnectAtSlot(TConn conn, bool failed) override
bool LoadSeq_idInfo(CReaderRequestResult &result, const CSeq_id_Handle &seq_id, const SAnnotSelector *with_named_accs)
virtual void x_RemoveConnectionSlot(TConn conn) override
bool LoadGiSeq_ids(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
CDB_Connection * x_GetConnection(TConn conn)
virtual bool LoadSeq_idAccVer(CReaderRequestResult &result, const CSeq_id_Handle &seq_id) override
virtual void x_AddConnectionSlot(TConn conn) override
virtual bool LoadSeq_idSeq_ids(CReaderRequestResult &result, const CSeq_id_Handle &seq_id) override
void x_ReceiveData(CReaderRequestResult &result, SPubseqReaderReceiveData &data, const TBlobId &blob_id, I_BaseCmd &cmd, bool force_blob)
virtual void SetIncludeHUP(bool include_hup=true, const string &web_cookie=NcbiEmptyString) override
virtual bool LoadSequenceHash(CReaderRequestResult &result, const CSeq_id_Handle &seq_id) override
TConnections m_Connections
virtual void GetBlobVersion(CReaderRequestResult &result, const CBlob_id &blob_id) override
virtual bool LoadSeq_idBlob_ids(CReaderRequestResult &result, const CSeq_id_Handle &seq_id, const SAnnotSelector *sel) override
All LoadXxx() methods should return false if there is no requested data in the reader.
CPubseqReader(int max_connections=0, const string &server=kEmptyStr, const string &user=kEmptyStr, const string &pswd=kEmptyStr, const string &dbapi_driver=kEmptyStr)
virtual bool LoadSeq_idGi(CReaderRequestResult &result, const CSeq_id_Handle &seq_id) override
Note about the "buf_size" parameter for streams in this API.
Definition: rwstream.hpp:122
const CProcessor & GetProcessor(CProcessor::EType type) const
Definition: dispatcher.cpp:219
void LoadSeq_idGi(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
void LoadSequenceHash(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
void LoadSeq_idSeq_ids(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
vector< CSeq_id_Handle > TSeqIds
Definition: reader.hpp:96
CReadDispatcher * m_Dispatcher
Definition: reader.hpp:344
void SetAndSaveSeq_idAccVer(CReaderRequestResult &result, const CSeq_id_Handle &seq_id, const TSequenceAcc &acc_id) const
Definition: reader.cpp:1173
void SetAndSaveNoSeq_idBlob_ids(CReaderRequestResult &result, const CSeq_id_Handle &seq_id, const SAnnotSelector *sel, const CLoadLockGi &gi_lock) const
Definition: reader.cpp:1133
void SetAndSaveSeq_idGi(CReaderRequestResult &result, const CSeq_id_Handle &seq_id, const TSequenceGi &gi) const
Definition: reader.cpp:1160
int TBlobVersion
Definition: reader.hpp:91
vector< CBlob_Info > TBlobIds
Definition: reader.hpp:97
void SetAndSaveNoBlob(CReaderRequestResult &result, const TBlobId &blob_id, TChunkId chunk_id, TBlobState blob_state)
Definition: reader.cpp:992
void x_SetIncludeHUP(bool include_hup)
Definition: reader.hpp:359
void SetAndSaveSeq_idSeq_ids(CReaderRequestResult &result, const CSeq_id_Handle &seq_id, const CFixedSeq_ids &seq_ids) const
Definition: reader.cpp:1050
unsigned TConn
Definition: reader.hpp:87
void x_ReportDisconnect(const char *reader, const char *server, TConn conn, bool failed) const
Definition: reader.cpp:444
virtual bool LoadSeq_idAccVer(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
Definition: reader.cpp:509
virtual void OpenConnection(TConn conn)
Definition: reader.cpp:326
CDataLoader::SHashFound TSequenceHash
Definition: reader.hpp:186
void SetAndSaveSeq_idBlob_ids(CReaderRequestResult &result, const CSeq_id_Handle &seq_id, const SAnnotSelector *sel, CLoadLockBlobIds &lock, const CLoadLockBlobIds &blob_ids) const
Definition: reader.cpp:1268
int TChunkId
Definition: reader.hpp:93
void SetAndSaveSequenceHash(CReaderRequestResult &result, const CSeq_id_Handle &seq_id, const TSequenceHash &hash) const
Definition: reader.cpp:1212
void InitParams(CConfig &conf, const string &driver_name, int default_max_conn)
Definition: reader.cpp:131
int SetMaximumConnections(int max)
Definition: reader.cpp:228
int TBlobState
Definition: reader.hpp:90
void SetAndSaveNoSeq_idSeq_ids(CReaderRequestResult &result, const CSeq_id_Handle &seq_id, TState state) const
Definition: reader.cpp:1149
CDataLoader::SGiFound TSequenceGi
Definition: reader.hpp:184
CRef –.
Definition: ncbiobj.hpp:618
CSafeStatic<>::
Template class helps to implement one driver class factory.
static string GetUserName(void)
Get actual user name for the current process.
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
Definition: tempstr.hpp:65
definition of a Culling tree
Definition: ncbi_tree.hpp:100
CVersionInfo –.
CZipStreamDecompressor – zlib based decompression stream processor.
Definition: zlib.hpp:817
A very basic data-read interface.
I_BaseCmd::
Definition: interfaces.hpp:436
void erase(iterator pos)
Definition: map.hpp:167
static CS_COMMAND * cmd
Definition: ct_dynamic.c:26
static CS_CONNECTION * conn
Definition: ct_dynamic.c:25
#define DBLB_INSTALL_DEFAULT_EX(if_set)
Easy-to-use macro to install the default DBAPI service mapper, with control over what to do if a conn...
int failed
Definition: dbmorecmds.c:10
void reset(element_type *p=0, EOwnership ownership=eTakeOwnership)
Reset will delete the old pointer (if owned), set content to the new value, and assume the ownership ...
Definition: ncbimisc.hpp:480
#define GI_FROM(T, value)
Definition: ncbimisc.hpp:1086
element_type * get(void) const
Get pointer.
Definition: ncbimisc.hpp:469
Int8 TIntId
Definition: ncbimisc.hpp:999
#define ZERO_GI
Definition: ncbimisc.hpp:1088
element_type * release(void)
Release will release ownership of pointer to caller.
Definition: ncbimisc.hpp:472
#define GI_TO(T, gi)
Definition: ncbimisc.hpp:1085
@ eTakeOwnership
An object can take ownership of another.
Definition: ncbi_types.h:136
I_DriverContext * GetDriverContext(const string &driver_name, string *err_msg=0, const map< string, string > *attr=0)
Definition: driver_mgr.cpp:308
@ eDB_StatusResult
Definition: interfaces.hpp:390
@ eDB_RowResult
Definition: interfaces.hpp:387
virtual EDB_ResType ResultType() const
Get type of the result.
Definition: public.cpp:603
virtual bool SkipItem()
Skip result item.
Definition: public.cpp:690
virtual CDB_LangCmd * LangCmd(const string &lang_query)
Make language command.
Definition: public.cpp:355
virtual size_t ReadItem(void *buffer, size_t buffer_size, bool *is_null=0)
Read a result item body (for BLOB columns, mostly).
Definition: public.cpp:678
virtual CDB_Object * GetItem(CDB_Object *item_buf=0, EGetItem policy=eAppendLOB)
Get a result item (you can use either GetItem or ReadItem).
Definition: public.cpp:672
virtual const char * ItemName(unsigned int item_num) const
Get name of a result item.
Definition: public.cpp:624
virtual unsigned int NofItems() const
Get # of items (columns) in the result.
Definition: public.cpp:617
virtual CDB_RPCCmd * RPC(const string &rpc_name)
Make remote procedure call command.
Definition: public.cpp:362
virtual bool Fetch()
Fetch next row.
Definition: public.cpp:649
virtual void AssignValue(const CDB_Object &v)
Definition: types.cpp:1252
const char * Value(void) const
Definition: types.hpp:537
virtual void AssignValue(const CDB_Object &v)
Definition: types.cpp:693
Int4 Value() const
Definition: types.hpp:373
Int8 Value() const
Definition: types.hpp:454
bool IsNULL() const
Definition: types.hpp:303
@ eDB_VarChar
Definition: types.hpp:57
@ eDB_TinyInt
Definition: types.hpp:55
@ eDB_Int
Definition: types.hpp:53
@ eDB_SmallInt
Definition: types.hpp:54
#define _TRACE(message)
Definition: ncbidbg.hpp:122
#define _VERIFY(expr)
Definition: ncbidbg.hpp:161
#define LOG_POST_X_ONCE(err_subcode, message)
Definition: ncbidiag.hpp:624
#define ERR_POST_X(err_subcode, message)
Error posting with default error code and given error subcode.
Definition: ncbidiag.hpp:550
#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_THROW_FMT(exception_class, err_code, message)
The same as NCBI_THROW but with message processed as output to ostream.
Definition: ncbiexpt.hpp:719
string GetString(const string &driver_name, const string &param_name, EErrAction on_error, const string &default_value, const list< string > *synonyms=NULL)
Utility function to get an element of parameter tree Throws an exception when mandatory parameter is ...
bool GetBool(const string &driver_name, const string &param_name, EErrAction on_error, bool default_value, const list< string > *synonyms=NULL)
Utility function to get an integer element of parameter tree Throws an exception when mandatory param...
@ eErr_NoThrow
Return default value on error.
CConstRef< CSeq_id > GetSeqId(void) const
static CSeq_id_Handle GetGiHandle(TGi gi)
Faster way to create a handle for a gi.
bool IsGi(void) const
static CSeq_id_Handle GetHandle(const CSeq_id &id)
Normal way of getting a handle, works for any seq-id.
string AsString(void) const
CSeq_id::E_Choice Which(void) const
TGi GetGi(void) const
bool IsIncludedAnyNamedAnnotAccession(void) const
check if any named annot accession is included in the search
bool IsIncludedNamedAnnotAccession(const string &acc) const
check if named annot accession is included in the search
SAnnotSelector & IncludeNamedAnnotAccession(const string &acc, int zoom_level=0)
#define NCBI_PARAM_TYPE(section, name)
Generate typename for a parameter from its {section, name} attributes.
Definition: ncbi_param.hpp:149
@ eParam_NoThread
Do not use per-thread values.
Definition: ncbi_param.hpp:418
static void NCBI_EntryPointImpl(TDriverInfoList &info_list, EEntryPointRequest method)
Entry point implementation.
#define NCBI_INTERFACE_VERSION(iface)
Macro to construct CVersionInfo class using interface name (relies on CInterfaceVersion class)
list< SDriverInfo > TDriverInfoList
List of driver information.
EEntryPointRequest
Actions performed by the entry point.
int32_t Int4
4-byte (32-bit) signed integer
Definition: ncbitype.h:102
int64_t Int8
8-byte (64-bit) signed integer
Definition: ncbitype.h:104
#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
ERW_Result
Result codes for I/O operations.
@ eRW_NotImplemented
Action / information is not available.
@ eRW_Eof
End of data, should be considered permanent.
@ eRW_Success
Everything is okay, I/O completed.
#define kEmptyStr
Definition: ncbistr.hpp:123
static list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
Definition: ncbistr.cpp:3457
static CStringUTF8 SQLEncode(const CStringUTF8 &str, ESqlEncode flag)
SQL-encode string.
Definition: ncbistr.cpp:6136
static enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
Definition: ncbistr.hpp:673
@ eSqlEnc_TagNonASCII
Produce N'...' when input's not pure ASCII.
Definition: ncbistr.hpp:3168
#define DEFINE_STATIC_FAST_MUTEX(id)
Define static fast mutex and initialize it.
Definition: ncbimtx.hpp:496
@ eNonCompatible
major, minor does not match
@ e_Gi
GenInfo Integrated Database.
Definition: Seq_id_.hpp:106
Definition of all error codes used in objtools libraries.
char * buf
int i
static MDB_envinfo info
Definition: mdb_load.c:37
static int version
Definition: mdb_load.c:29
string s_Value(TValue value)
#define nullptr
Definition: ncbimisc.hpp:45
std::istream & in(std::istream &in_, double &x_)
@ fBlobHasNamedFeat
Definition: blob_id.hpp:154
@ fBlobHasAllLocal
Definition: blob_id.hpp:182
Helper classes and templates to implement plugins.
#define DEFAULT_DB_PASSWORD
#define MAX_MT_CONN
#define DEFAULT_DB_DRIVER
#define RPC_GET_ASN
#define DEFAULT_NUM_CONN
#define DEFAULT_DB_USER
static TIntId sx_GetIntId(CDB_Result &dbr, int pos)
#define DEFAULT_EXCL_WGS_MASTER
static void sx_SetIntId(CDB_RPCCmd &cmd, const char *param, TIntId id)
void NCBI_EntryPoint_ReaderPubseqos(CPluginManager< objects::CReader >::TDriverInfoList &info_list, CPluginManager< objects::CReader >::EEntryPointRequest method)
#define DEFAULT_DB_SERVER
NCBI_PARAM_DECL(int, GENBANK, PUBSEQOS_DEBUG)
NCBI_PARAM_DEF_EX(int, GENBANK, PUBSEQOS_DEBUG, 0, eParam_NoThread, GENBANK_PUBSEQOS_DEBUG)
static int GetDebugLevel(void)
void GenBankReaders_Register_Pubseq(void)
void NCBI_EntryPoint_xreader_pubseqos(CPluginManager< objects::CReader >::TDriverInfoList &info_list, CPluginManager< objects::CReader >::EEntryPointRequest method)
#define RPC_GET_BLOB_INFO
#define DEFAULT_ALLOW_GZIP
@ fZipType_gzipped
#define NCBI_GBLOADER_READER_PUBSEQ_PARAM_SERVER
#define NCBI_GBLOADER_READER_PUBSEQ_PARAM_USER
#define NCBI_GBLOADER_READER_PUBSEQ_PARAM_EXCL_WGS_MASTER
#define NCBI_GBLOADER_READER_PUBSEQ_DRIVER_NAME
#define NCBI_GBLOADER_READER_PUBSEQ_PARAM_GZIP
#define NCBI_GBLOADER_READER_PUBSEQ_PARAM_PASSWORD
#define NCBI_GBLOADER_READER_PUBSEQ_PARAM_DRIVER
@ eAlreadyLoaded
Reader-writer based streams.
static const char * str(char *buf, int n)
Definition: stats.c:84
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,...
SAnnotSelector –.
AutoPtr< CDB_Result > dbr
CReader::TBlobState blob_state
CReader::TBlobVersion blob_version
Definition: _hash_fun.h:40
#define _ASSERT
else result
Definition: token2.c:20
ZLib Compression API.
Modified on Sat Dec 09 04:43:46 2023 by modify_doxy.py rev. 669887