61 #define NCBI_USE_ERRCODE_X ID2SNPProcessor
67 #define TRACE_PROCESSING
77 #define DEFAULT_VDB_CACHE_SIZE 10
78 #define DEFAULT_INDEX_UPDATE_TIME 600
79 #define DEFAULT_COMPRESS_DATA CID2SNPContext::eCompressData_some
177 typename Cont::value_type::TObjectType&
sx_AddNew(Cont& cont)
188 obj.
SetType().SetStr(
"AnnotationTrack");
189 obj.
AddField(
"ZoomLevel", zoom_level);
240 size_t hash_pos = acc_filter.
find(
'#');
241 if ( hash_pos ==
NPOS ) {
247 acc[0] !=
'N' || acc[1] !=
'A' || acc[2+
kNAIndexDigits] !=
'.' ) {
263 size_t filter_index = NStr::StringToNumeric<size_t>(filter,
275 #ifdef TRACE_PROCESSING
279 # define START_TRACE() do { if(s_DebugLevel()>0)sw.Restart(); } while(0)
286 # define TRACE_X(t,l,m) \
288 if ( s_DebugEnabled(l) ) { \
289 LOG_POST_X(t, Info<<sw.Elapsed()<<": ID2SNP: "<<m); \
293 # define START_TRACE() do{}while(0)
294 # define TRACE_X(t,l,m) do{}while(0)
313 const char*
data =
static_cast<const char*
>(
buffer);
334 size += (*it)->size();
344 : m_CompressData(eCompressData_never),
345 m_ExplicitBlobState(
false),
352 const string& driver_name)
354 unique_ptr<CConfig::TParamTree> app_params;
358 params = app_params.get();
406 if ( *it2 ==
"*.blob-state" ) {
407 context.m_ExplicitBlobState =
true;
409 if ( *it2 ==
"vdb-snp" ) {
439 "Exception while opening SNP DB "<<na<<
": "<<exc);
444 "Exception while opening SNP DB "<<na<<
": "<<exc);
446 catch ( exception& exc ) {
448 "Exception while opening SNP DB "<<na<<
": "<<exc.what());
530 const string& acc_ver)
580 if ( !acc_ver.empty() ) {
583 if (
const CTextseq_id* text_id =
id.GetTextseq_Id() ) {
584 if ( text_id->IsSetAccession() && !text_id->GetAccession().empty() &&
585 text_id->IsSetVersion() && text_id->GetVersion() > 0 ) {
599 info.m_OriginalSeqIdType = request_type;
647 info->m_SNPTracks.push_back(track);
666 template<
class Values>
679 template<
class TValues>
685 TSeqPos dst_ind = pos_index / bit_values;
687 if (
TSeqPos first_offset = pos_index % bit_values ) {
688 TSeqPos first_count = bit_values - first_offset;
689 if ( !bits[dst_ind] ) {
693 src_ind += first_count;
695 while ( src_ind < values.
size() ) {
696 if ( !bits[dst_ind] ) {
700 src_ind += bit_values;
756 skeleton.
SetAnnot().push_back(annot);
765 if ( !
sx_HasNonZero(feat_chunks,
i*feat_per_graph, feat_per_graph) ) {
770 chunk.
SetId().Set(chunk_id);
772 annot_info.
SetName(graph_name);
784 if ( !feat_chunks[
i] ) {
789 chunk.
SetId().Set(chunk_id);
801 return Ref<CSerialObject>(split_info);
822 data.SetAnnots().push_back(annot);
831 data.SetAnnots().push_back(annot);
834 return Ref<CSerialObject>(chunk);
907 error.SetMessage(
"Invalid chunk id");
910 replies.back()->SetEnd_of_reply();
924 replies.push_back(
Ref(&main_reply));
940 replies.push_back(
Ref(&main_reply));
954 annot_info.
SetSeq_loc().SetWhole_seq_id(*seq_id);
963 annot_info.
SetSeq_loc().SetWhole_seq_id(*seq_id);
970 annot_info.
SetSeq_loc().SetWhole_seq_id(*seq_id);
978 replies.back()->SetReply().SetGet_blob_id().SetEnd_of_reply();
982 replies.back()->SetEnd_of_reply();
1010 if ( (*it)->GetRequest().IsInit() ) {
1014 if ( !
context->m_Context.m_AllowVDB ) {
1017 if ( !(*it)->IsSetSerial_number() ) {
1022 switch ( (*it)->GetRequest().Which() ) {
1025 (*it)->SetRequest().SetGet_blob_id());
1029 (*it)->SetRequest().SetGet_blob_info());
1033 (*it)->SetRequest().SetGet_chunks());
1039 packet.
Set().erase(it);
1042 if ( ret->m_SNPRequests.empty() ) {
1059 it->second, reply.
SetReply().SetGet_seq_id());
1063 it->second, reply.
SetReply().SetGet_blob_id());
1066 replies.push_back(
Ref(&reply));
1072 replies.push_back(
Ref(&reply));
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.
ECompressData m_CompressData
TSNPRequests m_SNPRequests
CRef< CSerialObject > x_LoadBlob(CID2SNPContext &context, SSNPEntryInfo &info)
static bool x_GetAccVer(string &acc_ver, const CSeq_id &id)
static void x_AddSeqIdRequest(CID2_Request_Get_Seq_id &request, CID2SNPProcessorPacketContext::SRequestInfo &info)
CID2_Blob_Id & x_GetBlobId(SSNPEntryInfo &id)
CRef< CID2SNPProcessorContext > CreateContext(void)
void ProcessReply(CID2_Reply &reply, CID2SNPProcessorParams ¶ms, CID2SNPProcessorState &state, TReplies &replies)
void x_ProcessReplyGetBlobId(CID2SNPContext &context, CID2SNPProcessorPacketContext &packet_context, CID2_Reply &main_reply, TReplies &replies, CID2SNPProcessorPacketContext::SRequestInfo &info, CID2_Reply_Get_Blob_Id &reply)
void WriteData(CID2SNPContext &context, const SSNPEntryInfo &seq, CID2_Reply_Data &data, const CSerialObject &obj)
CRef< CID2SNPProcessorState > ProcessPacket(CID2_Request_Packet &packet, CID2SNPProcessorParams ¶ms, TReplies &replies)
bool WorthCompressing(const SSNPEntryInfo &seq)
EProcessStatus x_ProcessGetChunks(CID2SNPContext &context, CID2SNPProcessorPacketContext &packet_context, TReplies &replies, CID2_Request &main_request, CID2S_Request_Get_Chunks &request)
CID2SNPContext m_InitialContext
SSNPEntryInfo x_ResolveBlobId(const CID2_Blob_Id &id)
vector< CRef< CID2_Reply > > TReplies
const CID2SNPContext & GetInitialContext(void) const
CRef< CSerialObject > x_LoadChunk(CID2SNPContext &context, SSNPEntryInfo &entry, int chunk_id)
CSNPDbSeqIterator & GetSeqIterator(SSNPEntryInfo &seq)
EProcessStatus x_ProcessGetBlobId(CID2SNPContext &context, CID2SNPProcessorPacketContext &packet_context, TReplies &replies, CID2_Request &main_request, CID2_Request_Get_Blob_Id &request)
void InitContext(CID2SNPContext &context, const CID2_Request &main_request)
CSNPDb GetSNPDb(const string &na)
~CID2SNPProcessor_Impl(void)
EProcessStatus x_ProcessGetBlobInfo(CID2SNPContext &context, CID2SNPProcessorPacketContext &packet_context, TReplies &replies, CID2_Request &main_request, CID2_Request_Get_Blob_Info &request)
void x_ProcessReplyGetSeqId(CID2SNPContext &context, CID2SNPProcessorPacketContext &packet_context, CID2_Reply &main_reply, TReplies &replies, CID2SNPProcessorPacketContext::SRequestInfo &info, CID2_Reply_Get_Seq_id &reply)
void ResetIteratorCache(SSNPEntryInfo &seq)
CID2SNPProcessor_Impl(const CConfig::TParamTree *params=0, const string &driver_name=kEmptyStr)
CID2S_Feat_type_Info –.
CID2S_Reply_Get_Chunk –.
CID2S_Request_Get_Chunks –.
CID2S_Seq_annot_Info –.
CID2S_Seq_id_Interval –.
CID2_Reply_Get_Blob_Id –.
CID2_Reply_Get_Seq_id –.
CID2_Request_Get_Blob_Id –.
CID2_Request_Get_Blob_Info –.
CID2_Request_Get_Seq_id –.
CNcbiOstrstreamToString class helps convert CNcbiOstrstream to a string Sample usage:
list< TOctetString * > TOctetStringSequence
virtual ERW_Result Flush(void)
Flush pending data (if any) down to the output device.
COSSWriter(TOctetStringSequence &out)
TOctetStringSequence & m_Output
vector< char > TOctetString
virtual ERW_Result Write(const void *buffer, size_t count, size_t *written)
Write up to "count" bytes from the buffer pointed to by the "buf" argument onto the output device.
CObjectOStreamAsnBinary –.
CRef< CSeq_annot > GetOverviewAnnot(CRange< TSeqPos > range, const string &annot_name, TFlags flags=fDefaultFlags) const
CRef< CSeq_id > GetSeqId(void) const
TSeqPos GetCoverageZoom(void) const
TSeqPos GetOverviewZoom(void) const
TSeqPos GetMaxSNPLength(void) const
CRef< CSeq_annot > GetCoverageAnnot(CRange< TSeqPos > range, const string &annot_name, TFlags flags=fDefaultFlags) const
void SetTrack(const CSNPDbTrackIterator &track)
TAnnotSet GetTableFeatAnnots(CRange< TSeqPos > range, const string &annot_name, const SFilter &filter, TFlags flags=fDefaultFlags) const
CRange< TSeqPos > GetSNPRange(void) const
size_t GetVDBSeqIndex(void) const
size_t GetTrackCount() const
TSeqPos GetLength(void) const
Base class for all serializable objects.
@ 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 ...
definition of a Culling tree
CUser_object & AddField(const string &label, const string &value, EParseField parse=eParse_String)
add a data field to the user object that holds a given value
Writer-based output stream.
CZipStreamCompressor – zlib based compression stream processor.
A very basic data-write interface.
const_iterator end() const
const_iterator find(const key_type &key) const
Abstract reader-writer interface classes.
std::ofstream out("events_result.xml")
main entry point for tests
static const char * str(char *buf, int n)
static CNcbiApplicationGuard InstanceGuard(void)
Singleton method.
unsigned int TSeqPos
Type for sequence locations and lengths.
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define ERASE_ITERATE(Type, Var, Cont)
Non-constant version with ability to erase current element, if container permits.
@ eNoOwnership
No ownership is assumed.
iterator find(const key_type &key)
void set_size_limit(size_t size_limit)
virtual const CTypeInfo * GetThisTypeInfo(void) const =0
#define MSerial_AsnText
I/O stream manipulators –.
static TParamTree * ConvertRegToTree(const IRegistry ®, NStr::ECase use_case=NStr::eNocase)
Reconstruct param tree from the application registry.
int GetInt(const string &driver_name, const string ¶m_name, EErrAction on_error, int 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.
static CSeq_id_Handle GetHandle(const CSeq_id &id)
Normal way of getting a handle, works for any seq-id.
string CombineWithZoomLevel(const string &acc, int zoom_level)
Combine accession string and zoom level into a string with separator.
CRef< C > Ref(C *object)
Helper functions to get CRef<> and CConstRef<> objects.
void Reset(void)
Reset reference object.
#define NCBI_PARAM_TYPE(section, name)
Generate typename for a parameter from its {section, name} attributes.
@ eParam_NoThread
Do not use per-thread values.
position_type GetToOpen(void) const
ERW_Result
Result codes for I/O operations.
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
@ eRW_Success
Everything is okay, I/O completed.
bool empty(void) const
Return true if the represented string is empty (i.e., the length is zero)
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 find(const CTempString match, size_type pos=0) const
Find the first instance of the entire matching string within the current string, beginning at an opti...
size_type size(void) const
Return the length of the represented array.
@ fConvErr_NoThrow
Do not throw an exception on error.
const TTreeType * FindSubNode(const TKeyType &key) const
Non recursive linear scan of all subnodes, with key comparison.
TTo GetTo(void) const
Get the To member data.
void SetType(TType &value)
Assign a value to Type data member.
bool IsSetAnnot_info(void) const
annotation types in this blob annotation are unknown if this field is omitted Check if a value has be...
bool IsSetValue(void) const
Check if a value has been assigned to Value data member.
const TSources & GetSources(void) const
Get the Sources member data.
void SetBlob_id(TBlob_id &value)
Assign a value to Blob_id data member.
const TChunks & GetChunks(void) const
Get the Chunks member data.
void ResetEnd_of_reply(void)
Reset End_of_reply data member.
void SetSerial_number(TSerial_number value)
Assign a value to Serial_number data member.
bool IsSetEnd_of_reply(void) const
this Blob-id is the last one in the request Check if a value has been assigned to End_of_reply data m...
void SetSeq_id_type(TSeq_id_type value)
Assign a value to Seq_id_type data member.
TSerial_number GetSerial_number(void) const
Get the Serial_number member data.
TSeq_id_type GetSeq_id_type(void) const
Get the Seq_id_type member data.
bool IsGet_seq_id(void) const
Check if variant Get_seq_id is selected.
TError & SetError(void)
Assign a value to Error data member.
const TSeq_id & GetSeq_id(void) const
Get the Seq_id member data.
void SetData(TData &value)
Assign a value to Data data member.
void SetReply(TReply &value)
Assign a value to Reply data member.
list< CRef< CID2_Param > > Tdata
TSources & SetSources(void)
Assign a value to Sources data member.
void SetBlob_id(TBlob_id &value)
Assign a value to Blob_id data member.
const TSeq_id & GetSeq_id(void) const
Get the variant data.
const TBlob_id & GetBlob_id(void) const
Get the variant data.
void SetBlob_id(TBlob_id &value)
Assign a value to Blob_id data member.
list< vector< char > * > TData
const TReply & GetReply(void) const
Get the Reply member data.
void SetSeq_id(TSeq_id &value)
Assign a value to Seq_id data member.
const TSeq_id & GetSeq_id(void) const
Get the Seq_id member data.
list< CID2S_Chunk_Id > TChunks
bool IsSetSerial_number(void) const
request's serial number, can be used in asynchronic clients server should copy it to corresponding fi...
Tdata & Set(void)
Assign a value to data member.
void ResetEnd_of_reply(void)
Reset End_of_reply data member.
TSerial_number GetSerial_number(void) const
Get the Serial_number member data.
void SetEnd_of_reply(void)
Set NULL data member (assign 'NULL' value to End_of_reply data member).
const Tdata & Get(void) const
Get the member data.
const TBlob_id & GetBlob_id(void) const
Get the Blob_id member data.
void ResetSources(void)
Reset Sources data member.
void SetData(TData &value)
Assign a value to Data data member.
bool IsSetSeq_id(void) const
resolved Seq-id not set if error occurred Check if a value has been assigned to Seq_id data member.
list< CRef< CID2_Request > > Tdata
bool IsSetSerial_number(void) const
request's serial number, copy from request Check if a value has been assigned to Serial_number data m...
bool IsSetParams(void) const
Check if a value has been assigned to Params data member.
bool IsBlob_id(void) const
Check if variant Blob_id is selected.
const TValue & GetValue(void) const
Get the Value member data.
const TBlob_id & GetBlob_id(void) const
Get the Blob_id member data.
TAnnot_info & SetAnnot_info(void)
Assign a value to Annot_info data member.
void SetBlob_id(TBlob_id &value)
Assign a value to Blob_id data member.
bool IsGet_blob_id(void) const
Check if variant Get_blob_id is selected.
const TParams & GetParams(void) const
Get the Params member data.
bool IsSetEnd_of_reply(void) const
true if this reply is the last one for the request false if more replies will follow Check if a value...
void SetChunk_id(const TChunk_id &value)
Assign a value to Chunk_id data member.
void SetSeq_id(TSeq_id &value)
Assign a value to Seq_id data member.
const TName & GetName(void) const
Get the Name member data.
bool IsSeq_id(void) const
Check if variant Seq_id is selected.
bool IsSetBlob_id(void) const
result Check if a value has been assigned to Blob_id data member.
bool IsSetSources(void) const
return id of blob with sequence Check if a value has been assigned to Sources data member.
@ eData_type_id2s_split_info
@ eSeq_id_type_any
return any qualified Seq-id
@ eSeq_id_type_text
text Seq-id (accession etc) is preferred
@ eSeq_id_type_all
return all qualified Seq-ids of the sequence
@ eSeverity_no_data
resolve request gives no data probably temporarily (see retry-delay field)
@ eData_format_asn_binary
void SetName(const TName &value)
Assign a value to Name data member.
void SetType(TType value)
Assign a value to Type data member.
TSubtypes & SetSubtypes(void)
Assign a value to Subtypes data member.
void SetSkeleton(TSkeleton &value)
Assign a value to Skeleton data member.
void SetId(const TId &value)
Assign a value to Id data member.
void SetSeq_loc(TSeq_loc &value)
Assign a value to Seq_loc data member.
TChunks & SetChunks(void)
Assign a value to Chunks data member.
void SetStart(TStart value)
Assign a value to Start data member.
TData & SetData(void)
Assign a value to Data data member.
TFeat & SetFeat(void)
Assign a value to Feat data member.
TContent & SetContent(void)
Assign a value to Content data member.
void SetSeq_id(TSeq_id &value)
Assign a value to Seq_id data member.
void SetGraph(void)
Set NULL data member (assign 'NULL' value to Graph data member).
void SetLength(TLength value)
Assign a value to Length data member.
TFrom GetFrom(void) const
Get the From member data.
const TInt & GetInt(void) const
Get the variant data.
const TInt & GetInt(void) const
Get the variant data.
const TGraph & GetGraph(void) const
Get the Graph member data.
const TValues & GetValues(void) const
Get the Values member data.
const TByte & GetByte(void) const
Get the variant data.
const TValues & GetValues(void) const
Get the Values member data.
bool IsByte(void) const
Check if variant Byte is selected.
const TLoc & GetLoc(void) const
Get the Loc member data.
TNumval GetNumval(void) const
Get the Numval member data.
TComp GetComp(void) const
Get the Comp member data.
TAnnot & SetAnnot(void)
Assign a value to Annot data member.
void SetId(TId &value)
Assign a value to Id data member.
TSeq_set & SetSeq_set(void)
Assign a value to Seq_set data member.
const TGraph & GetGraph(void) const
Get the variant data.
void SetDesc(TDesc &value)
Assign a value to Desc data member.
const TData & GetData(void) const
Get the Data member data.
#define DEFAULT_COMPRESS_DATA
SSNPDbTrackInfo ParseTrack(CTempString acc_filter)
static const TSeqPos kGraphChunkSize
static const EResolveMaster kResolveMaster
bool sx_HasNonZero(const Values &values, TSeqPos index, TSeqPos count)
#define DEFAULT_VDB_CACHE_SIZE
static bool s_FilterAll(void)
const int kFilterIndexCount
const int kNAVersionDigitsMin
static bool s_Enabled(void)
void sx_SetZoomLevel(CSeq_annot &annot, int zoom_level)
string FormatTrack(const SSNPDbTrackInfo &track)
static const TSeqPos kFeatChunkSize
const int kNAVersionDigitsMax
static void sx_AddBits(vector< char > &bits, TSeqPos kChunkSize, const CSeq_graph &graph)
static int s_DebugLevel(void)
const int kFilterIndexMaxLength
bool IsValidFilterIndex(size_t filter_index)
static const int kChunkIdMul
CNcbiOstream & operator<<(CNcbiOstream &out, const CID2SNPProcessor_Impl::SSNPEntryInfo &seq)
static bool s_DebugEnabled(EDebugLevel level)
bool IsValidNAVersion(size_t na_version)
NCBI_PARAM_DEF_EX(bool, ID2SNP, ENABLE, true, eParam_NoThread, ID2SNP_ENABLE)
static const int kChunkIdFeat
static const int kChunkIdGraph
@ eResolveMaster_without_gi
bool IsValidSeqIndex(size_t seq_index)
NCBI_DEFINE_ERR_SUBCODE_X(24)
bool IsValidNAIndex(size_t na_index)
string GetNAAccession(const SSNPDbTrackInfo &track)
void sx_AddBits2(vector< char > &bits, TSeqPos bit_values, TSeqPos pos_index, const TValues &values)
size_t sx_GetSize(const CID2_Reply_Data &data)
Cont::value_type::TObjectType & sx_AddNew(Cont &cont)
NCBI_PARAM_DECL(bool, ID2SNP, ENABLE)
#define NCBI_ID2PROC_SNP_PARAM_COMPRESS_DATA
#define NCBI_ID2PROC_SNP_PARAM_VDB_CACHE_SIZE
Definition of all error codes used in SRA C++ support libraries.
range(_Ty, _Ty) -> range< _Ty >
double value_type
The numeric datatype used by the parser.
const struct ncbi::grid::netcache::search::fields::SIZE size
string s_Value(TValue value)
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
Reader-writer based streams.
vector< SSNPDbTrackInfo > m_SNPTracks
CSNPDbSeqIterator m_SeqIter
CRef< CID2_Blob_Id > m_BlobId
int g(Seg_Gsm *spe, Seq_Mtf *psm, Thd_Gsm *tdg)
static CS_CONTEXT * context