65 srv_error.GetDescription())
79 if(!cache_file.empty()) {
88 if (args.
Exist(
"gc-cache") &&
89 args[
"gc-cache"].HasValue()) {
118 template<
typename TReq>
122 ostringstream ostrstrm;
130 if(acc.find_first_not_of(
"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_.") != string::npos)
140 const string SltSql =
"SELECT gc_blob FROM GetAssemblyBlob "
141 "WHERE acc_ver = ? AND mode = ?";
148 return CAsm->Assembly();
150 ERR_POST(
Info <<
"Cache query for " << acc <<
" and " <<
mode <<
" found nothing, fallback to remote service.");
169 ERR_POST(
Error <<
"Service failed to return result. Check applog for errors in gc_get_assembly_v3 and refresh_cache");
186 const string SltSql =
"SELECT gc_blob FROM GetAssemblyBlob "
187 "WHERE release_id = ? AND mode = ?";
189 Stmt.
Bind(1, releaseId);
194 return CAsm->Assembly();
210 ERR_POST(
Error <<
"Service failed to return result. Check applog for errors in gc_get_assembly_v3 and refresh_cache");
231 const int RETRY_MAX = 3;
232 for(retry_counter=1; retry_counter <= RETRY_MAX; retry_counter++) {
236 if( retry_counter == RETRY_MAX) {
264 return assm->CanGetAssemblies() && !assm->GetAssemblies().empty() ?
284 for(
auto acc : sequence_acc)
285 if(acc.length() > 30) {
289 req.
SetSequence_acc().assign(sequence_acc.begin(), sequence_acc.end());
300 const int RETRY_MAX = 3;
301 for(retry_counter=1; retry_counter <= RETRY_MAX; retry_counter++) {
305 if( retry_counter == RETRY_MAX) {
333 const int RETRY_MAX = 3;
334 for(retry_counter=1; retry_counter <= RETRY_MAX; retry_counter++) {
338 if( retry_counter == RETRY_MAX) {
364 if(!cache_file.empty() &&
CFile(cache_file).Exists()) {
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
CRef< objects::CGC_Assembly > Assembly()
Incapsulate compile time information such as __FILE__, __LINE__, NCBI_MODULE, current function.
CGCClient_GetAssemblyBlobRequest –.
CGCClient_GetEquivalentAssembliesRequest –.
CGCClient_ValidateChrTypeLocRequest –.
const char * GetErrCodeString(void) const override
Get error code interpreted as text.
CGCServiceException(const CDiagCompileInfo &diag, const objects::CGCClient_Error &srv_error)
CRef< CGCClient_EquivalentAssemblies > GetEquivalentAssemblies(const string &acc, int equivalency)
CGenomicCollectionsService(const string &cache_file="")
unique_ptr< CSQLITE_Connection > m_CacheConn
static void AddArguments(CArgDescriptions &arg_desc)
CRef< CGCClient_AssembliesForSequences > FindAssembliesBySequences(const string &sequence_acc, int filter, CGCClient_GetAssemblyBySequenceRequest::ESort sort=CGCClient_GetAssemblyBySequenceRequest::eSort_default, bool with_roles=false)
Find assemblies by sequence accession.
CRef< CGC_Assembly > GetAssembly(const string &acc, const string &mode)
~CGenomicCollectionsService()
void x_ConfigureConnection()
CRef< CGCClient_AssemblyInfo > FindOneAssemblyBySequences(const string &sequence_acc, int filter, CGCClient_GetAssemblyBySequenceRequest::ESort sort=CGCClient_GetAssemblyBySequenceRequest::eSort_default)
Find assembly by sequence accession.
string ValidateChrType(const string &chrType, const string &chrLoc)
CRef< CGCClient_AssembliesForSequences > x_FindAssembliesBySequences(const list< string > &sequence_acc, int filter, CGCClient_GetAssemblyBySequenceRequest::ESort sort, bool top_only, bool with_roles)
void x_ConfigureCache(const string &cache_file)
Connection to SQLite database.
@ fReadOnly
The DB is read-only. Also forces fVacuumOff flag.
static void Initialize(void)
Initialization of SQLite and tuning some default parameters.
static void Finalize(void)
Finish all SQLite operations.
SQL statement executing on SQLite database.
void Bind(int index, int val)
Bind integer value to parameter index.
bool Step(void)
Step through results of the statement.
string GetString(int col_ind) const
Get text value from column col_ind in current row.
static void ValidateAsmAccession(const string &acc)
static const STimeout kTimeout
void LogRequest(const TReq &req)
User-defined methods of the data storage class.
bool Exist(const string &name) const
Check existence of argument description.
void AddOptionalKey(const string &name, const string &synopsis, const string &comment, EType type, TFlags flags=0)
Add description for optional key without default value.
void SetCurrentGroup(const string &group)
Set current arguments group name.
@ eString
An arbitrary string.
#define DIAG_COMPILE_INFO
Make compile time diagnostic information object to use in CNcbiDiag and CException.
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
void Error(CExceptionArgs_Base &args)
TErrCode GetErrCode(void) const
Get error code.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
const string & GetMsg(void) const
Get message string.
void Warning(CExceptionArgs_Base &args)
EErrCode
Error types that an application can generate.
void Info(CExceptionArgs_Base &args)
void SetRetryLimit(unsigned int n)
void SetFormat(ESerialDataFormat fmt)
void SetArgs(const string &args)
Set additional connection arguments.
#define ENUM_METHOD_NAME(EnumName)
#define MSerial_AsnText
I/O stream manipulators –.
EIO_Status SetTimeout(const STimeout *timeout, EIO_Event direction=eIO_ReadWrite)
@ eFailed
Request (or retry) failed.
@ eSerial_AsnText
ASN.1 text.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static string TruncateSpaces(const string &str, ETrunc where=eTrunc_Both)
Truncate whitespace in a string.
void SetLocation(const TLocation &value)
Assign a value to Location data member.
virtual CRef< CGCClient_EquivalentAssemblies > AskGet_equivalent_assemblies(const CGCClient_GetEquivalentAssembliesRequest &req, TReply *reply=0)
void SetMode(const TMode &value)
Assign a value to Mode data member.
void SetFilter(TFilter value)
Assign a value to Filter data member.
void SetAccession(const TAccession &value)
Assign a value to Accession data member.
void SetAccession(const TAccession &value)
Assign a value to Accession data member.
TSequence_acc & SetSequence_acc(void)
Assign a value to Sequence_acc data member.
void SetTop_assembly_only(TTop_assembly_only value)
Assign a value to Top_assembly_only data member.
virtual vector< char > AskGet_assembly_blob(const CGCClient_GetAssemblyBlobRequest &req, TReply *reply=0)
void SetRelease_id(TRelease_id value)
Assign a value to Release_id data member.
void SetSort(TSort value)
Assign a value to Sort data member.
virtual CRef< CGCClient_AssembliesForSequences > AskGet_assembly_by_sequence(const CGCClient_GetAssemblyBySequenceRequest &req, TReply *reply=0)
void SetType(const TType &value)
Assign a value to Type data member.
virtual string AskGet_chrtype_valid(const CGCClient_ValidateChrTypeLocRequest &req, TReply *reply=0)
void SetEquivalency(TEquivalency value)
Assign a value to Equivalency data member.
bool IsSrvr_error(void) const
Check if variant Srvr_error is selected.
const TSrvr_error & GetSrvr_error(void) const
Get the variant data.
void SetAdd_sequence_roles(TAdd_sequence_roles value)
Assign a value to Add_sequence_roles data member.
constexpr auto sort(_Init &&init)
void SleepSec(unsigned long sec, EInterruptOnSignal onsignal=eRestartOnSignal)
Sleep.
Defines command line argument related classes.