69 #define NCBI_USE_ERRCODE_X Objtools_Reader_Id1
74 #define DEFAULT_SERVICE "ID1"
75 #define DEFAULT_NUM_CONN 3
79 #define GENBANK_ID1_RANDOM_FAILS_FREQUENCY 20
80 #define GENBANK_ID1_RANDOM_FAILS_RECOVER 0
82 #ifdef GENBANK_ID1_RANDOM_FAILS
85 static int fail_recover = 0;
86 if ( fail_recover > 0 ) {
92 stream.setstate(ios::badbit);
96 # define SetRandomFail(stream)
132 ERR_POST_X_ONCE(2,
"This app is using OM++ ID1 reader which is being phased out. Please switch to using ID2 or PSG.");
138 const string& driver_name)
140 ERR_POST_X_ONCE(2,
"This app is using OM++ ID1 reader which is being phased out. Please switch to using ID2 or PSG.");
147 if ( service_name.empty() ) {
148 service_name =
NCBI_PARAM_TYPE(GENBANK,ID1_SERVICE_NAME)::GetDefault();
150 if ( service_name.empty() ) {
222 #ifdef GENBANK_ID1_RANDOM_FAILS
226 if ( stream.bad() ) {
296 if ( ids_lock.IsLoaded() ) {
310 sc_SatMap.find(dbtag.
GetDb().c_str()) != sc_SatMap.end() ) {
313 seq_ids.push_back(seq_id);
320 if ( !gi_lock.IsLoaded() ) {
333 if ( !gi_ids_lock.IsLoaded() ) {
345 if ( ids.IsLoaded() ) {
351 if ( seq_id.
IsGi() ) {
370 if ( !id1_reply.
IsIds() ) {
388 for (
auto& s : accs ) {
389 if ( s.first !=
"SNP" ) {
402 if ( ids.IsLoaded() ) {
418 if (
id.GetGeneral().GetTag().GetId8(num) && num != 0 ) {
419 const CDbtag& dbtag =
id.GetGeneral();
420 const string& db = dbtag.
GetDb();
422 if ( iter != sc_SatMap.end() ) {
425 ESat sat = iter->second.first;
427 Int4 sub_sat = iter->second.second;
432 sub_sat |=
Int4((num>>32)<<16);
434 blob_id->SetSat(sat);
435 blob_id->SetSatKey(sat_key);
436 blob_id->SetSubSat(sub_sat);
445 if ( !gi_lock.IsLoaded() ) {
458 if ( !gi_ids_lock.IsLoaded() ) {
471 if ( ids.IsLoaded() ) {
476 if ( seq_id.
IsGi() ) {
506 if (
info.GetBlob_state() < 0 ) {
509 if (
info.GetSuppress() & 5 ) {
511 (
info.GetSuppress() == 4)
515 if (
info.GetWithdrawn() > 0) {
520 if (
info.GetConfidential() > 0) {
525 if (
info.GetSat() < 0 ||
info.GetSat_key() < 0 ) {
538 blob_id->SetSat(
info.GetSat());
539 blob_id->SetSatKey(
info.GetSat_key());
542 if (
info.IsSetExtfeatmask() ) {
549 blob_id->SetSat(
info.GetSat());
550 blob_id->SetSatKey(
info.GetSat_key());
551 if (
info.IsSetExtfeatmask() ) {
552 blob_id->SetSubSat(
info.GetExtfeatmask());
579 switch ( reply.
Which() ) {
597 "invalid ID1server-back.");
599 "CId1Reader::GetBlobVersion: "
600 "invalid ID1server-back");
642 "ID1server-back.error "<<
error);
645 "unknown ID1server-back.error "<<
error);
680 "failed to receive reply: "+
725 #ifdef GENBANK_ID1_RANDOM_FAILS
735 s <<
" ID1server-request";
746 "failed to send request: "+
751 s <<
"Sent ID1server-request.";
761 #ifdef GENBANK_ID1_RANDOM_FAILS
766 s <<
"Receiving ID1server-back...";
774 "failed to receive reply: "+
784 s <<
" ID1server-back.";
819 objects::CReader* drv = 0;
825 drv =
new objects::CId1Reader(params, driver);
TSatKey GetSatKey() const
TSubSat GetSubSat() const
Base class, inherited from "std::iostream", does both input and output, using the specified CONNECTOR...
@ID1server_back.hpp User-defined methods of the data storage class.
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)
Class factory for ID1 reader.
CSimpleClassFactoryImpl< objects::CReader, objects::CId1Reader > TParent
objects::CReader * CreateInstance(const string &driver=kEmptyStr, CVersionInfo version=NCBI_INTERFACE_VERSION(objects::CReader), const TPluginManagerParamTree *params=0) const
Create instance of TDriver.
void GetBlobVersion(CReaderRequestResult &result, const CBlob_id &blob_id)
CReaderServiceConnector m_Connector
void GetBlobState(CReaderRequestResult &result, const CBlob_id &blob_id)
virtual void x_AddConnectionSlot(TConn conn)
void x_SetParams(CID1server_maxcomplex ¶ms, const CBlob_id &blob_id)
TBlobState x_ResolveId(CReaderRequestResult &result, CID1server_back &id1_reply, CID1server_request &id1_request)
void x_ReceiveReply(TConn conn, CID1server_back &reply)
bool LoadSeq_idSeq_ids(CReaderRequestResult &result, const CSeq_id_Handle &id)
bool LoadSeq_idBlob_ids(CReaderRequestResult &result, const CSeq_id_Handle &id, const SAnnotSelector *sel)
All LoadXxx() methods should return false if there is no requested data in the reader.
void x_SendRequest(TConn conn, CID1server_request &request)
CId1Reader(int max_connections=0)
virtual void x_RemoveConnectionSlot(TConn conn)
void x_SetBlobRequest(CID1server_request &request, const CBlob_id &blob_id)
void GetBlob(CReaderRequestResult &result, const TBlobId &blob_id, TChunkId chunk_id)
CConn_IOStream * x_GetConnection(TConn conn)
bool LoadSeq_idGi(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
string x_ConnDescription(CConn_IOStream &stream) const
virtual void x_ConnectAtSlot(TConn conn)
virtual void x_DisconnectAtSlot(TConn conn, bool failed)
TConnections m_Connections
bool LoadGiBlob_ids(CReaderRequestResult &result, const CSeq_id_Handle &seq_id, const SAnnotSelector *sel)
bool LoadGiSeq_ids(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
int GetMaximumConnectionsLimit(void) const
bool SetNoBlob_ids(const CFixedBlob_ids::TState &state, TExpirationTime expiration_time)
bool SetLoadedBlob_ids(const TData &data, TExpirationTime expiration_time)
bool IsLoadedChunk(void) const
bool IsLoadedGi(void) const
static bool IsFound(const TData &data)
static TGi GetGi(const TData &data)
bool SetLoadedSeq_ids(const TData &data)
Data loader exceptions, used by GenBank loader.
CObjectIStreamAsnBinary –.
CObjectOStreamAsnBinary –.
static TGi ConvertGiFromOM(TGi gi)
static void OffsetAllGisToOM(CBeginInfo obj, CTSE_SetObjectInfo *set_info=0)
virtual void ProcessStream(CReaderRequestResult &result, const TBlobId &blob_id, TChunkId chunk_id, CNcbiIstream &stream) const
static bool TrySNPSplit(void)
static void OffsetAllGisFromOM(CBeginInfo obj)
const CProcessor & GetProcessor(CProcessor::EType type) const
void LoadSeq_idGi(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
void LoadSeq_idSeq_ids(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
void LoadSeq_idBlob_ids(CReaderRequestResult &result, const CSeq_id_Handle &seq_id, const SAnnotSelector *sel)
void RememberIfBad(SConnInfo &conn_info)
void SetTimeoutTo(STimeout *tmout) const
void InitTimeouts(CConfig &conf, const string &driver_name)
SConnInfo Connect(int error_count=0)
string GetConnDescription(CConn_IOStream &stream) const
void SetServiceName(const string &service_name)
vector< CSeq_id_Handle > TSeqIds
CReadDispatcher * m_Dispatcher
void SetAndSaveNoSeq_idBlob_ids(CReaderRequestResult &result, const CSeq_id_Handle &seq_id, const SAnnotSelector *sel, const CLoadLockGi &gi_lock) const
void SetAndSaveSeq_idGi(CReaderRequestResult &result, const CSeq_id_Handle &seq_id, const TSequenceGi &gi) const
void SetAndSaveBlobVersion(CReaderRequestResult &result, const TBlobId &blob_id, TBlobVersion version) const
vector< CBlob_Info > TBlobIds
void SetAndSaveBlobState(CReaderRequestResult &result, const TBlobId &blob_id, TBlobState blob_state) const
void SetAndSaveSeq_idSeq_ids(CReaderRequestResult &result, const CSeq_id_Handle &seq_id, const CFixedSeq_ids &seq_ids) const
void x_ReportDisconnect(const char *reader, const char *server, TConn conn, bool failed) const
virtual void OpenConnection(TConn conn)
void SetAndSaveSeq_idBlob_ids(CReaderRequestResult &result, const CSeq_id_Handle &seq_id, const SAnnotSelector *sel, CLoadLockBlobIds &lock, const CLoadLockBlobIds &blob_ids) const
void InitParams(CConfig &conf, const string &driver_name, int default_max_conn)
int SetMaximumConnections(int max)
virtual bool LoadSeq_idBlob_ids(CReaderRequestResult &result, const CSeq_id_Handle &seq_id, const SAnnotSelector *sel)
All LoadXxx() methods should return false if there is no requested data in the reader.
void SetAndSaveNoSeq_idSeq_ids(CReaderRequestResult &result, const CSeq_id_Handle &seq_id, TState state) const
Template class helps to implement one driver class factory.
class CStaticArrayMap<> is an array adaptor that provides an STLish interface to statically-defined a...
TBase::const_iterator const_iterator
definition of a Culling tree
std::ofstream out("events_result.xml")
main entry point for tests
static CS_CONNECTION * conn
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 ...
#define GI_FROM(T, value)
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
element_type * get(void) const
Get pointer.
@ eTakeOwnership
An object can take ownership of another.
EIO_Status CONN_SetTimeout(CONN conn, EIO_Event event, const STimeout *timeout)
Specify timeout for the connection I/O, including "Connect" (aka "Open") and "Close".
#define LOG_POST_X(err_subcode, message)
#define ERR_POST_X_ONCE(err_subcode, message)
Error posting only once during program execution with default error code and given error subcode.
#define ERR_POST_X(err_subcode, message)
Error posting with default error code and given error subcode.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
void Warning(CExceptionArgs_Base &args)
#define NCBI_THROW_FMT(exception_class, err_code, message)
The same as NCBI_THROW but with message processed as output to ostream.
#define NCBI_RETHROW(prev_exception, exception_class, err_code, message)
Generic macro to re-throw an exception.
#define MSerial_AsnText
I/O stream manipulators –.
string GetString(const string &driver_name, const string ¶m_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 ...
@ 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.
static CSeq_id_Handle GetHandle(const CSeq_id &id)
Normal way of getting a handle, works for any seq-id.
CSeq_id::E_Choice Which(void) const
CBeginInfo Begin(C &obj)
Get starting point of object hierarchy.
bool IsIncludedAnyNamedAnnotAccession(void) const
check if any named annot accession is included in the search
const TNamedAnnotAccessions & GetNamedAnnotAccessions(void) const
#define NCBI_PARAM_TYPE(section, name)
Generate typename for a parameter from its {section, name} attributes.
@ eParam_NoThread
Do not use per-thread values.
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
int64_t Int8
8-byte (64-bit) signed integer
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define END_SCOPE(ns)
End the previously defined scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
#define BEGIN_SCOPE(ns)
Define a new scope.
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.
unsigned int usec
microseconds (modulo 1,000,000)
@ eIO_ReadWrite
eIO_Read | eIO_Write (also, eCONN_OnFlush)
@ eIO_Close
also serves as an error indicator in SOCK_Poll
@ eNonCompatible
major, minor does not match
const TTag & GetTag(void) const
Get the Tag member data.
const TDb & GetDb(void) const
Get the Db member data.
void SetEnt(TEnt value)
Assign a value to Ent data member.
const TGotblobinfo & GetGotblobinfo(void) const
Get the variant data.
void SetGi(TGi value)
Assign a value to Gi data member.
bool IsIds(void) const
Check if variant Ids is selected.
TBlob_state GetBlob_state(void) const
Get the Blob_state member data.
TGetsefromgi & SetGetsefromgi(void)
Select the variant.
E_Choice Which(void) const
Which variant is currently selected.
TError GetError(void) const
Get the variant data.
bool IsError(void) const
Check if variant Error is selected.
bool IsGotgi(void) const
Check if variant Gotgi is selected.
const TGotsewithinfo & GetGotsewithinfo(void) const
Get the variant data.
void SetSat(const TSat &value)
Assign a value to Sat data member.
TGotgi GetGotgi(void) const
Get the variant data.
const TIds & GetIds(void) const
Get the variant data.
TGetblobinfo & SetGetblobinfo(void)
Select the variant.
void SetMaxplex(TMaxplex value)
Assign a value to Maxplex data member.
TGetseqidsfromgi & SetGetseqidsfromgi(void)
Select the variant.
TGetsewithinfo & SetGetsewithinfo(void)
Select the variant.
TGetgi & SetGetgi(void)
Select the variant.
list< CRef< CSeq_id > > TIds
bool IsGotblobinfo(void) const
Check if variant Gotblobinfo is selected.
const TBlob_info & GetBlob_info(void) const
Get the Blob_info member data.
@ eEntry_complexities_entry
the "natural" entry for this (nuc-prot)
TGi GetGi(void) const
Get the variant data.
const TGeneral & GetGeneral(void) const
Get the variant data.
@ e_General
for other databases
@ e_Gi
GenInfo Integrated Database.
string s_Value(TValue value)
Multi-threading – mutexes; rw-locks; semaphore.
std::istream & in(std::istream &in_, double &x_)
Helper classes and templates to implement plugins.
static const TSI sc_SatIndex[]
static bool sx_IsSNPOnly(const SAnnotSelector::TNamedAnnotAccessions &accs)
#define GENBANK_ID1_RANDOM_FAILS_RECOVER
void NCBI_EntryPoint_xreader_id1(CPluginManager< objects::CReader >::TDriverInfoList &info_list, CPluginManager< objects::CReader >::EEntryPointRequest method)
DEFINE_STATIC_ARRAY_MAP(TSatMap, sc_SatMap, sc_SatIndex)
void GenBankReaders_Register_Id1(void)
NCBI_PARAM_DECL(int, GENBANK, ID1_DEBUG)
SStaticPair< TRDR::ESat, TRDR::ESubSat > TSK
static int GetDebugLevel(void)
void NCBI_EntryPoint_Id1Reader(CPluginManager< objects::CReader >::TDriverInfoList &info_list, CPluginManager< objects::CReader >::EEntryPointRequest method)
#define GENBANK_ID1_RANDOM_FAILS_FREQUENCY
SStaticPair< const char *, TSK > TSI
#define SetRandomFail(stream)
NCBI_PARAM_DEF_EX(int, GENBANK, ID1_DEBUG, 0, eParam_NoThread, GENBANK_ID1_DEBUG)
CStaticPairArrayMap< const char *, TSK, PNocase_CStr > TSatMap
#define NCBI_GBLOADER_READER_ID1_PARAM_SERVICE_NAME
#define NCBI_GBLOADER_READER_ID1_DRIVER_NAME
Better replacement of GetGi(), this method should be defined in data loaders, GetGi() is left for com...
AutoPtr< CConn_IOStream > m_Stream
Template structure SStaticPair is simlified replacement of STL pair<> Main reason of introducing this...