57 using namespace std::placeholders;
65 m_Errors.push_back(err);
74 size_t err_count = m_Errors.size();
75 string msg =
"\n" + to_string(err_count) +
" error";
79 msg +=
" encountered while resolving ";
81 if (seq_id_to_resolve.size() == 1) {
82 msg +=
"the seq id:\n";
84 msg +=
"multiple seq ids:\n";
87 for (
size_t index=0; index < err_count; ++index) {
91 msg += m_Errors[index].m_ErrorMessage;
104 for (
const auto & item : m_Errors) {
105 combined_code =
max(combined_code, item.m_ErrorCode);
107 return combined_code;
116 shared_ptr<CPSGS_Request> request,
117 shared_ptr<CPSGS_Reply> reply,
122 m_ContinueResolveCB(continue_resolve_cb),
123 m_FinishedCB(finished_cb),
125 m_StartProcessingCB(start_processing_cb),
126 m_ResolveStage(eInit),
130 m_StartProcessingCalled(
false)
141 list<string> && secondary_id_list,
142 string && primary_seq_id,
166 if (text_seq_id ==
nullptr)
179 bool need_comma =
false;
183 seq_ids += item.seq_id;
197 if (!seq_id.empty()) {
202 for (
const auto & item : annot_request.
m_SeqIds) {
208 m_Reply->SendTrace(
"The seq_ids to resolve list before sorting: " +
220 m_Reply->SendTrace(
"The seq_ids to resolve list after sorting: " +
259 "Not handled request type " +
280 "Not handled request type " +
357 "Not handled request type " +
358 to_string(
static_cast<int>(
m_Request->GetRequestType())));
368 m_Reply->SendTrace(
"Accession adjustment is not required "
369 "(bioseq info is not provided)",
378 m_Reply->SendTrace(
"Accession adjustment is not required "
379 "(substitute option is 'never')",
394 m_Reply->SendTrace(
"Accession adjustment is not required "
395 "(It is PDB, PIR or PRF with version == 0 "
396 "and substitute option is 'default')",
408 m_Reply->SendTrace(
"Accession adjustment is not required "
409 "(substitute option is 'limited' and seq_id_type is not gi)",
509 bool with_seq_id_type)
517 unique_ptr<CCassBioseqInfoFetch> details;
524 if (with_seq_id_type) {
525 if (seq_id_type != -1)
529 bioseq_info_request.
SetGI(gi);
534 bioseq_keyspace.keyspace,
537 details->SetLoader(fetch_task);
539 if (with_seq_id_type)
551 if (with_seq_id_type) {
560 if (with_seq_id_type)
562 "Cassandra request: " +
567 "Cassandra request for INSDC types: " +
581 unique_ptr<CCassSi2csiFetch> details;
586 if (effective_seq_id_type != -1)
592 bioseq_keyspace.keyspace,
596 details->SetLoader(fetch_task);
609 "Cassandra request: " +
648 auto record_count = records.size();
655 string msg = to_string(records.size()) +
" hit(s)";
656 for (
const auto & item : records) {
663 if (record_count > 1) {
665 if (index_to_pick < 0) {
668 to_string(records.size()) +
" bioseq info records were "
669 "found however it was impossible to choose one of them. "
670 "So report as not found",
679 if (record_count != 1) {
681 if (record_count > 1) {
684 app->GetCounters().Increment(
this,
689 app->GetCounters().Increment(
this,
704 string msg =
"Data inconsistency. ";
705 if (record_count > 1) {
706 msg +=
"More than one BIOSEQ_INFO table record is found for "
709 msg +=
"A BIOSEQ_INFO table record is not found for "
739 if (records.size() == 1)
740 prefix =
"Selected record:\n";
742 prefix =
"Record with max version (and max date changed if "
743 "more than one with max version) selected "
744 "(SEQ_STATE_LIFE records are checked first)\n";
760 string msg =
"BIOSEQ_INFO Cassandra error: " +
782 app->GetCounters().Increment(
this,
790 vector<CBioseqInfoRecord>&& records)
799 string msg = to_string(records.size()) +
800 " hit(s); decision status: " + to_string(
decision.status);
801 for (
const auto & item : records) {
816 app->GetCounters().Increment(
this,
826 app->GetCounters().Increment(
this,
830 string msg =
"Data inconsistency. A BIOSEQ_INFO table record "
831 "is not found for accession " +
855 app->GetCounters().Increment(
this,
858 string msg =
"Data inconsistency. More than one BIOSEQ_INFO "
859 "table record is found for accession " +
885 string msg =
"Unexpected decision code when a secondary INSCD "
886 "request results processed while resolving seq id asynchronously";
907 EDiagSev severity,
const string & message)
941 auto record_count = records.size();
948 string msg = to_string(record_count) +
" hit(s)";
949 for (
const auto & item : records) {
952 if (record_count > 1)
953 msg +=
"\nMore than one record => may be more tries";
958 if (record_count != 1) {
960 if (record_count > 1) {
963 app->GetCounters().Increment(
this,
968 app->GetCounters().Increment(
this,
981 app->GetCounters().Increment(
this,
986 bioseq_info.
SetVersion(records[0].GetVersion());
988 bioseq_info.
SetGI(records[0].GetGI());
1005 EDiagSev severity,
const string & message)
1044 m_Reply->SendTrace(
"Could not resolve seq_id " + current_seq_id +
1045 ". There are more seq_id to try, switching to the next one.",
1055 string msg =
"Could not resolve ";
1060 msg +=
"any of the seq_ids: ";
1061 bool is_first =
true;
1080 if (async_bioseq_resolution.IsValid()) {
1093 app->GetCounters().Increment(
this,
1098 if (async_bioseq_resolution.m_Error.HasError()) {
1100 async_bioseq_resolution.m_Error.m_ErrorCode);
function< void(SBioseqResolution &&async_bioseq_resolution)> TSeqIdResolutionFinishedCB
function< void(void)> TSeqIdResolutionStartProcessingCB
function< void(void)> TContinueResolveCB
function< void(CRequestStatus::ECode status, int code, EDiagSev severity, const string &message, EPSGS_LoggingFlag logging_flag)> TSeqIdResolutionErrorCB
ssize_t SelectBioseqInfoRecord(const vector< CBioseqInfoRecord > &records)
CBioseqInfoFetchRequest & SetVersion(CBioseqInfoRecord::TVersion value)
CBioseqInfoFetchRequest & SetGI(CBioseqInfoRecord::TGI value)
CBioseqInfoFetchRequest & SetSeqIdType(CBioseqInfoRecord::TSeqIdType value)
CBioseqInfoFetchRequest & SetAccession(CBioseqInfoRecord::TAccession const &value)
TSeqIdType GetSeqIdType() const
TVersion GetVersion() const
CBioseqInfoRecord & SetSeqIdType(TSeqIdType value)
CBioseqInfoRecord & SetGI(TGI value)
TAccession const & GetAccession() const
CBioseqInfoRecord & SetVersion(TVersion value)
CBioseqInfoRecord & SetAccession(const TAccession &value)
void SetDataReadyCB(shared_ptr< CCassDataCallbackReceiver > callback)
void SetConsumeCallback(TBioseqInfoConsumeCallback callback)
void SetErrorCB(TDataErrorCallback error_cb)
void SetReadFinished(void)
CCassBlobWaiter * GetLoader(void)
void SetDataReadyCB(shared_ptr< CCassDataCallbackReceiver > callback)
void SetConsumeCallback(TSI2CSIConsumeCallback callback)
@ ePSGS_BioseqInfoNotFound
@ ePSGS_BioseqInfoFoundMany
@ ePSGS_InputSeqIdNotResolved
@ ePSGS_BioseqInfoFoundOne
void Increment(IPSGS_Processor *processor, EPSGS_CounterType counter)
CRequestStatus::ECode GetCombinedErrorCode(void) const
bool HasErrors(void) const
void AppendError(const string &msg, CRequestStatus::ECode code)
string GetCombinedErrorMessage(const list< SPSGSeqId > &seq_id_to_resolve) const
string GetCouldNotResolveMessage(void) const
bool MoveToNextSeqId(void)
SPSGS_RequestBase::EPSGS_AccSubstitutioOption GetAccessionSubstitutionOption(void)
string x_GetSeqIdsToResolveList(void) const
psg_time_point_t m_BioseqInfoStart
void x_OnBioseqInfoWithoutSeqIdType(vector< CBioseqInfoRecord > &&records)
list< SPSGSeqId > m_SeqIdsToResolve
psg_time_point_t m_AsyncCassResolutionStart
void x_SignalStartProcessing(void)
int16_t x_GetRequestSeqIdType(void)
void x_OnSi2csiError(CRequestStatus::ECode status, int code, EDiagSev severity, const string &message)
TSeqIdResolutionErrorCB m_ErrorCB
psg_time_point_t m_Si2csiStart
int16_t m_EffectiveSeqIdType
CBioseqInfoRecord::TSeqIdType m_BioseqInfoRequestedSeqIdType
list< string > m_SecondaryIdList
void x_PreparePrimaryBioseqInfoQuery(const CBioseqInfoRecord::TAccession &seq_id, CBioseqInfoRecord::TVersion version, CBioseqInfoRecord::TSeqIdType seq_id_type, CBioseqInfoRecord::TGI gi, bool with_seq_id_type)
virtual ~CPSGS_AsyncResolveBase()
CBioseqInfoRecord::TGI m_BioseqInfoRequestedGI
SBioseqResolution m_BioseqResolution
SPSGS_ResolveRequest::TPSGS_BioseqIncludeData GetBioseqInfoFields(void)
void SetupSeqIdToResolve(void)
void x_OnBioseqInfoError(CRequestStatus::ECode status, int code, EDiagSev severity, const string &message)
bool CanSkipBioseqInfoRetrieval(const CBioseqInfoRecord &bioseq_info_record)
int16_t m_EffectiveVersion
CPSGSResolveErrors m_ResolveErrors
list< SPSGSeqId >::const_iterator m_CurrentSeqIdToResolve
bool NonKeyBioseqInfoFieldsRequested(void)
void x_OnBioseqInfo(vector< CBioseqInfoRecord > &&records)
void x_PrepareSecondaryAsIsSi2csiQuery(void)
TContinueResolveCB m_ContinueResolveCB
bool m_StartProcessingCalled
CCassFetch * m_NoSeqIdTypeFetch
EPSGS_AccessionAdjustmentResult AdjustBioseqAccession(SBioseqResolution &bioseq_resolution)
string x_GetRequestSeqId(void)
CCassFetch * m_CurrentFetch
TSeqIdResolutionStartProcessingCB m_StartProcessingCB
CBioseqInfoRecord::TVersion m_BioseqInfoRequestedVersion
TSeqIdResolutionFinishedCB m_FinishedCB
int16_t GetEffectiveVersion(const CTextseq_id *text_seq_id)
EPSGS_ResolveStage m_ResolveStage
void x_OnSi2csiRecord(vector< CSI2CSIRecord > &&records)
void x_OnSeqIdAsyncResolutionFinished(SBioseqResolution &&async_bioseq_resolution)
CBioseqInfoRecord::TAccession m_BioseqInfoRequestedAccession
void x_PrepareSecondarySi2csiQuery(void)
void x_PrepareSi2csiQuery(const string &secondary_id, int16_t effective_seq_id_type)
list< unique_ptr< CCassFetch > > m_FetchDetails
bool IsTimeoutError(const string &msg) const
static string TypeToString(EPSGS_Type req_type)
@ ePSGS_AnnotationRequest
@ ePSGS_IPGResolveRequest
@ ePSGS_AccessionVersionHistoryRequest
@ ePSGS_BlobBySeqIdRequest
CPSGSCounters & GetCounters(void)
static CPubseqGatewayApp * GetInstance(void)
SSatInfoEntry GetBioseqKeyspace(void) const
CSi2CsiFetchRequest & SetSecSeqId(CSI2CSIRecord::TSecSeqId const &value)
CSi2CsiFetchRequest & SetSecSeqIdType(CSI2CSIRecord::TSecSeqIdType value)
virtual void Process(void)=0
Main processing function.
shared_ptr< CPSGS_Reply > m_Reply
shared_ptr< CPSGS_Request > m_Request
static DLIST_TYPE *DLIST_NAME() next(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
EDiagSev
Severity level for the posted diagnostics.
@ eDiag_Error
Error message.
@ e500_InternalServerError
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
static string & ToUpper(string &str)
Convert string to upper case – string& version.
TVersion GetVersion(void) const
Get the Version member data.
bool CanGetVersion(void) const
Check if it is safe to call GetVersion method.
@ e_Gi
GenInfo Integrated Database.
SINSDCDecision DecideINSDC(const vector< CBioseqInfoRecord > &records, CBioseqInfoRecord::TVersion version)
bool IsINSDCSeqIdType(CBioseqInfoRecord::TSeqIdType seq_id_type)
const string version
version string
Defines NCBI C++ diagnostic APIs, classes, and macros.
const CConstRef< CSeq_id > GetAccession(const CSeq_id_Handle &id_handle)
string StripTrailingVerticalBars(const string &seq_id)
void PSGSortSeqIds(list< SPSGSeqId > &seq_ids, IPSGS_Processor *processor)
string ToJsonString(const CBioseqInfoRecord &bioseq_info, SPSGS_ResolveRequest::TPSGS_BioseqIncludeData include_data_flags, const string &custom_blob_id)
#define PSG_WARNING(message)
@ ePSGS_BioseqInfoAccessionAdjustmentError
@ ePSGS_NoBioseqInfoForGiError
EPSGS_AccessionAdjustmentResult
string SanitizeInputValue(const string &input_val)
Defines CRequestStatus class for NCBI C++ diagnostic API.
static SLJIT_INLINE sljit_ins msg(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
EPSGS_AccessionAdjustmentResult AdjustAccession(shared_ptr< CPSGS_Request > request, shared_ptr< CPSGS_Reply > reply)
EPSGS_ResolutionResult m_ResolutionResult
CBioseqInfoRecord & GetBioseqInfo(void)
void SetBioseqInfo(const CBioseqInfoRecord &record)
vector< string > m_SeqIds
EPSGS_AccSubstitutioOption
@ ePSGS_LimitedAccSubstitution
@ ePSGS_DefaultAccSubstitution
@ ePSGS_NeverAccSubstitute
int TPSGS_BioseqIncludeData