81 if (!seq_id)
return ret;
83 if (!text_id)
return ret;
84 if (text_id->CanGetAccession() && text_id->CanGetVersion() &&
85 !text_id->GetAccession().empty() && text_id->GetVersion() > 0) {
98 size_t size = s.size();
100 while (pos &&
isdigit(s[pos - 1])) {
103 size_t num_len =
size - pos;
108 size_t index = NStr::StringToNumeric<size_t>(s.substr(pos));
128 template<
class Container>
129 typename Container::value_type::TObjectType&
s_AddObject(Container& container)
132 container.push_back(obj);
144 string id2info =
str;
145 size_t pos = id2info.find_last_of(
".");
146 if (pos ==
NPOS || pos + 1 >= id2info.size())
return;
147 split_version = NStr::StringToNumeric<int>(id2info.substr(pos + 1));
149 pos = id2info.find_last_of(
".");
150 if (pos ==
NPOS)
return;
151 NStr::StringToNumeric<int>(id2info.substr(pos + 1));
179 m_IsPrimaryTrack(
false),
180 m_IsPrimaryTrackGraph(
false),
182 m_FilterIndex(
Uint4(filter_index)),
193 m_IsPrimaryTrack(
false),
194 m_IsPrimaryTrackGraph(
false),
195 m_SeqIndex(
Uint4(seq_index)),
196 m_FilterIndex(
Uint4(filter_index))
198 if (
file.IsValidNA()) {
223 return na_index > 0 && na_index < 1000000000;
313 pair<size_t, size_t> ret(0, 0);
315 if (acc.
size() < 13 || acc.
size() > 15 ||
316 acc[0] !=
'N' || acc[1] !=
'A' || acc[11] !=
'.') {
319 size_t na_index = NStr::StringToNumeric<size_t>(acc.
substr(2, 9),
324 size_t na_version = NStr::StringToNumeric<size_t>(acc.
substr(12),
329 ret.first = na_index;
330 ret.second = na_version;
346 pair<size_t, size_t> na =
ParseNA(acc);
424 size_t dot1 =
str.find(
'/');
428 size_t dot2 =
str.find(
'.', dot1 + 1);
432 size_t sat = NStr::StringToNumeric<size_t>(
str.substr(0, dot1),
439 size_t subsat = NStr::StringToNumeric<size_t>(
str.substr(dot1 + 1, dot2 - dot1 - 1),
441 bool is_primary_track_graph = is_primary_track && subsat >=
kSNPSubSatGraph;
442 size_t na_index = subsat - (is_primary_track_graph ?
kSNPSubSatGraph : 0);
447 size_t satkey = NStr::StringToNumeric<size_t>(
str.substr(dot2 + 1),
487 "Bad CSNPBlobId: " <<
str);
502 m_SeqIndex(it.GetVDBSeqIndex()),
504 m_IsPrimaryTrack(
false),
505 m_IsPrimaryTrackGraph(
false)
507 if (!
file->IsValidNA()) {
609 : m_IsValidNA(
false),
610 m_RemainingOpenRetries(
client.m_Config.m_FileOpenRetry)
688 if (!request.
m_SeqId.empty()) {
692 catch (exception& e) {}
698 catch (exception& e) {}
708 if (!idh)
return false;
728 if (
id.
empty() )
return false;
737 if ( text_id->IsSetVersion() ||
version > 0 ) {
777 PSG_INFO(
"PSGS_SNP: GetFileInfo: opened " << acc <<
" has expired");
784 slot->SetObject(
info);
786 if ( !
info->m_SNPDb &&
info->m_RemainingOpenRetries > 0 ) {
788 --
info->m_RemainingOpenRetries;
797 info->m_RemainingOpenRetries = 0;
801 PSG_ERROR(
"PSGS_SNP: Exception while opening SNP DB " << acc <<
": " << exc);
802 if (
info->m_RemainingOpenRetries > 0 ) {
807 PSG_ERROR(
"PSGS_SNP: assume DB " << acc <<
" is not SNP");
813 PSG_ERROR(
"PSGS_SNP: Exception while opening SNP DB " << acc <<
": " << exc);
814 if (
info->m_RemainingOpenRetries > 0 ) {
819 PSG_ERROR(
"PSGS_SNP: assume DB " << acc <<
" is not SNP");
822 catch ( exception& exc ) {
824 PSG_ERROR(
"PSGS_SNP: Exception while opening SNP DB " << acc <<
": " << exc.what());
825 if (
info->m_RemainingOpenRetries > 0 ) {
830 PSG_ERROR(
"PSGS_SNP: assume DB " << acc <<
" is not SNP");
835 if ( !
info->m_SNPDb ) {
851 vector<string> can_process;
853 for (
const auto& name : (priority==-1?
857 can_process.push_back(name);
862 if (filter_index == 0 && acc.size() == name.size()) {
867 can_process.push_back(name);
894 if (chunk_request.
m_Id2Chunk < 0)
return false;
896 return parsed_info.
blob_id.get();
908 vector<SSNPData> ret;
913 if (!
id.IsAllowedSNPScaleLimit(scale_limit))
return ret;
917 if (acc_ver.empty()) {
922 string na_acc =
m_PTISClient->GetPrimarySnpTrackForAccVer(acc_ver);
925 if (na_acc.empty()) {
965 if (filter_index == 0 && acc.size() == name.size()) {
980 data.m_BlobId = blob_id.ToString();
983 string overview_name =
986 string coverage_name =
992 catch ( exception& exc ) {
995 data.m_Error =
"Exception when handling get_na request: " +
string(exc.what());
1015 if (!parsed_info.
blob_id)
return ret;
1025 annot_info->SetName(name);
1026 auto& feat_type =
s_AddObject(annot_info->SetFeat());
1029 annot_info->SetSeq_loc().SetWhole_seq_id().Assign(*
id.
GetSeqId());
1037 annot_info->SetName(name);
1038 annot_info->SetGraph();
1039 annot_info->SetSeq_loc().SetWhole_seq_id().Assign(*
id.
GetSeqId());
1049 GetTiming().Register(
nullptr,
operation, status, start, 0);
User-defined methods of the data storage class.
CID2S_Seq_annot_Info –.
CNcbiOstrstreamToString class helps convert CNcbiOstrstream to a string Sample usage:
EPSGS_Type GetRequestType(void) const
@ ePSGS_AnnotationRequest
@ ePSGS_BlobBySatSatKeyRequest
TRequest & GetRequest(void)
static CPubseqGatewayApp * GetInstance(void)
Int4 GetSubSat(void) const
void SetPrimaryTrackFeat()
bool IsValidSatKey(void) const
static bool IsValidSeqIndex(size_t seq_index)
bool m_IsPrimaryTrackGraph
int GetSubSatBase(void) const
bool IsValidSat(void) const
size_t GetFilterIndex(void) const
string ToString(void) const
Get string representation of blob id.
CSNPBlobId(const CTempString &str)
static bool IsValidNAIndex(size_t index)
static bool IsValidNAVersion(size_t version)
void FromString(CTempString str)
void SetSatNA(CTempString acc)
void SetSeqAndFilterIndex(size_t seq_index, size_t filter_index)
size_t GetNAVersion(void) const
static pair< size_t, size_t > ParseNA(CTempString acc)
void SetNAIndex(size_t na_index)
static bool IsValidNA(pair< size_t, size_t > na)
Int4 GetSatKey(void) const
void SetNAVersion(size_t na_version)
size_t GetNAIndex(void) const
bool FromSatString(CTempString str)
bool IsPrimaryTrackGraph() const
int GetSatBase(void) const
bool IsValidSubSat(void) const
bool IsPrimaryTrack() const
CSeq_id_Handle GetSeqId(void) const
static bool IsValidFilterIndex(size_t filter_index)
string GetAccession(void) const
string GetSatNA(void) const
size_t GetSeqIndex(void) const
void SetPrimaryTrackGraph()
SSNPProcessor_Config m_Config
bool CanProcessRequest(CPSGS_Request &request, TProcessorPriority priority) const
SSNPData GetChunk(const string &id2info, int chunk_id)
void x_RegisterTiming(psg_time_point_t start, EPSGOperation operation, EPSGOperationStatus status)
bool IsValidSeqId(const objects::CSeq_id_Handle &idh) const
friend class CSNPFileInfo
vector< SSNPData > GetAnnotInfo(const objects::CSeq_id_Handle &id, const string &name, objects::CSeq_id::ESNPScaleLimit scale_limit)
CRef< objects::CSnpPtisClient > m_PTISClient
CRef< objects::CID2S_Seq_annot_Info > x_GetGraphInfo(const string &name, const objects::CSeq_id_Handle &id)
CSNPClient(const SSNPProcessor_Config &config)
CRef< CSNPSeqInfo > GetSeqInfo(const CSNPBlobId &blob_id)
CRef< CSNPFileInfo > GetFileInfo(const string &acc)
vector< string > WhatNACanProcess(SPSGS_AnnotRequest &annot_request, TProcessorPriority priority=0) const
shared_ptr< objects::CVDBMgr > m_Mgr
bool HaveValidSeq_id(const SPSGS_AnnotRequest &request) const
SSNPData GetBlobByBlobId(const string &blob_id)
CRef< objects::CID2S_Seq_annot_Info > x_GetFeatInfo(const string &name, const objects::CSeq_id_Handle &id)
pair< CRef< CID2S_Split_Info >, TSplitVersion > GetSplitInfoAndVersion(const string &base_name, TFlags flags=fDefaultFlags) const
void SetTrack(const CSNPDbTrackIterator &track)
CSNPDb_Impl & GetDb(void) const
const CSeq_id_Handle & GetSeqIdHandle(void) const
CRef< CSeq_entry > GetEntry(const string &base_name, TFlags flags=fDefaultFlags) const
CRef< CID2S_Chunk > GetChunkForVersion(const string &base_name, TChunkId chunk_id, TSplitVersion split_version) const
size_t GetVDBSeqIndex(void) const
const string & GetDbPath(void) const
CRef< CSNPSeqInfo > GetSeqInfo(const CSeq_id_Handle &seq_id)
const string & GetBaseAnnotName(void) const
void x_Initialize(CSNPDataLoader_Impl &impl, const string &file_name)
CSNPFileInfo(CSNPDataLoader_Impl &impl, const string &file_name)
string GetSNPAnnotName(size_t filter_index) const
CSNPSeqInfo(CSNPFileInfo *file, const CSNPDbSeqIterator &it)
bool m_IsPrimaryTrackGraph
CSNPDbSeqIterator GetSeqIterator(void) const
void SetFromBlobId(const CSNPBlobId &blob_id)
void SetFilterIndex(size_t filter_index)
void LoadBlob(SSNPData &data, bool split_enabled)
string GetAnnotName(void) const
CRef< CSNPBlobId > GetBlobId(void) const
void LoadChunk(SSNPData &data, int chunk_id)
static string CombineWithZoomLevel(const string &acc, int zoom_level)
Combine accession string and zoom level into a string with separator.
static CRef< CSnpPtisClient > CreateClient()
@ eProtectedDb
DB is protected.
@ eNotFoundDb
DB main file not found.
virtual TErrCode GetErrCode(void) const
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
CRef< CSlot > GetSlot(const string &acc_or_path)
std::ofstream out("events_result.xml")
main entry point for tests
static const char * str(char *buf, int n)
#define NCBI_THROW_FMT(exception_class, err_code, message)
The same as NCBI_THROW but with message processed as output to ostream.
static EAccessionInfo IdentifyAccession(const CTempString &accession, TParseFlags flags=fParse_AnyRaw)
Deduces information from a bare accession a la WHICH_db_accession; may report false negatives on prop...
void Reset(void)
Reset the handle (remove seq-id reference)
CSeq_id::EAccessionInfo IdentifyAccession(void) const
bool IsAccVer(void) const
static CSeq_id_Handle GetHandle(const CSeq_id &id)
Normal way of getting a handle, works for any seq-id.
const CTextseq_id * GetTextseq_Id(void) const
Return embedded CTextseq_id, if any.
ESNPScaleLimit
SNP annotation scale limits.
void Swap(TThisType &ref)
Swaps the pointer with another reference.
int32_t Int4
4-byte (32-bit) signed integer
unsigned char Uchar
Alias for unsigned char.
uint32_t Uint4
4-byte (32-bit) unsigned integer
uint16_t Uint2
2-byte (16-bit) unsigned integer
NCBI_NS_STD::string::size_type SIZE_TYPE
CTempString substr(size_type pos) const
Obtain a substring from this string, beginning at a given offset.
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.
size_type size(void) const
Return the length of the represented array.
@ fConvErr_NoThrow
Do not throw an exception on error.
CGuard< CRWLock, SSimpleWriteLock< CRWLock > > TWriteLockGuard
@ e_Other
for historical reasons, 'other' = 'refseq'
constexpr bool empty(list< Ts... >) noexcept
const string version
version string
double value_type
The numeric datatype used by the parser.
const struct ncbi::grid::netcache::search::fields::SIZE size
void split(std::vector< std::string > *strVec, const std::string &str_, const std::string &split_)
const CConstRef< CSeq_id > GetAccession(const CSeq_id_Handle &id_handle)
#define PSG_ERROR(message)
#define PSG_INFO(message)
psg_clock_t::time_point psg_time_point_t
static bool GetSeqId(const T &d, set< string > &labels, const string name="", bool detect=false, bool found=false)
static CNamedPipeClient * client
static const char kFileEnd[]
static size_t s_ExtractFilterIndex(string &s)
const int kFilterIndexCount
Container::value_type::TObjectType & s_AddObject(Container &container)
const int kSNPSubSatGraph
const int kFilterIndexMaxLength
static const char kFilterPrefixChar
const unsigned int kRefSeqAccFlags
static string s_GetAccVer(const CSeq_id_Handle &id)
static string s_AddFilterIndex(const string &s, size_t filter_index)
vector< string > GetNotProcessedName(TProcessorPriority priority)
vector< string > m_SeqIds
SParsedId2Info(const string &str)
unique_ptr< CSNPBlobId > blob_id
objects::CSeq_id::ESNPScaleLimit m_SNPScaleLimit