TBuffer = std::vector<unsigned char>;
76 m_Index->SetCacheSize(128 * 1024 * 1024);
80 if( !
CFile(main_fname).Exists() ) {
82 "cannot open ASN cache: failed to find file: "+ main_fname);
88 if(
CFile(fname).Exists()) {
97 ERR_POST(
Error<<
"error opening seq-id cache: disabling: "<< e);
106vector<CAsnIndex::SIndexInfo>&
info,
109 boolwas_id_found =
false;
124cursor.From << seq_id <<
version;
127 while(cursor.Fetch() ==
eBDB_Ok) {
130 if(current_info.seq_id != seq_id) {
135 boolshould_report = (!
version||
version== current_info.version) &&
141(
info[0].version < current_info.version ||
142(
info[0].version == current_info.version &&
info[0].timestamp < current_info.timestamp))) ||
144(
version&&
info[0].timestamp < current_info.timestamp))
147was_id_found =
true;
151 info.push_back(current_info);
162vector<CAsnIndex::SIndexInfo> info_vector;
166 info= info_vector[0];
172time_t& this_timestamp)
186this_timestamp =
info.timestamp;
199 Uint4& sequence_length,
208timestamp =
info.timestamp;
210sequence_length =
info.sequence_length;
211tax_id =
info.taxonomy_id;
216vector<CSeq_id_Handle>& all_ids,
219 boolwas_seqid_blob_found =
false;
226<<
" gi="<<
info.gi
227<<
" timestamp="<<
info.timestamp
228<<
" offs="<<
info.offs
229<<
" size="<<
info.size);
231 if( was_seqid_blob_found ){
236 ERR_POST(
"Unable to read or unpack a SeqIds chunk." 237<<
" offset = "<<
info.offs <<
" size = "<<
info.size );
238 ERR_POST(
"SeqId = "<<
id.AsString() <<
" gi = "<<
info.gi
239<<
" timestamp = "<<
info.timestamp );
241was_seqid_blob_found =
false;
244 else if(!cheap_only) {
253was_seqid_blob_found =
true;
257 returnwas_seqid_blob_found;
263 boolwas_blob_found =
false;
269 if(! was_blob_found ) {
279<<
" gi="<<
info.gi
280<<
" timestamp="<<
info.timestamp
281<<
" chunk="<<
info.chunk
282<<
" offs="<<
info.offs
283<<
" size="<<
info.size);
300 ERR_POST(
"Unable to read or unpack a raw chunk. ChunkId = "<<
info.chunk
301<<
" offset = "<<
info.offs <<
" size = "<<
info.size );
303<<
" timestamp = "<<
info.timestamp );
313vector<CAsnIndex::SIndexInfo>
info;
317 if(! was_blob_found ) {
321 ITERATE(vector<CAsnIndex::SIndexInfo>, blob_it,
info) {
324blobs.push_back(blob);
327 return!blobs.empty();
344vector< CRef<CCache_blob> > blobs;
348 buffer.resize(blobs.size());
350(*blob_it)->UnPack(
buffer[blob_it - blobs.begin()]);
356 boolCAsnCacheStore::EfficientlyGetSeqIds()
const 375vector< CRef<CSeq_entry> >
entries;
376vector< CRef<CCache_blob> > blobs;
380(*blob_it)->UnPack(*entry);
396vector<CAsnIndex::SIndexInfo> &
info)
405std::set<CAsnIndex::TGi> gi_set;
411 autogi = index_ref.GetGi();
415 returngi_set.size();
425cb(index_ref.GetSeqId(),
426index_ref.GetVersion(),
428index_ref.GetTimestamp());
439cb(index_ref.GetSeqId(),
440index_ref.GetVersion(),
442index_ref.GetTimestamp(),
443index_ref.GetChunkId(),
444index_ref.GetOffset(),
446index_ref.GetSeqLength(),
447index_ref.GetTaxId());
455: m_Index(db_paths.
size())
459 for(
auto const& db_path: db_paths ) {
460std::unique_ptr<IAsnCacheStore> store(
new CAsnCacheStore(db_path) );
461 m_Stores.push_back(std::move(store));
468std::shuffle(
m_Index.begin(),
m_Index.end(), default_random_engine());
481std::shuffle(
m_Index.begin(),
m_Index.end(), default_random_engine());
494std::shuffle(
m_Index.begin(),
m_Index.end(), default_random_engine());
507std::shuffle(
m_Index.begin(),
m_Index.end(), default_random_engine());
525vector<objects::CSeq_id_Handle>& all_ids,
528std::shuffle(
m_Index.begin(),
m_Index.end(), default_random_engine());
543 boolCAsnCacheStoreMany::EfficientlyGetSeqIds()
const 551std::shuffle(
m_Index.begin(),
m_Index.end(), default_random_engine());
554 autoentry =
m_Stores[
i]->GetEntry(
id);
565std::shuffle(
m_Index.begin(),
m_Index.end(), default_random_engine());
574 returnvector<CRef<CSeq_entry> >();
584std::shuffle(
m_Index.begin(),
m_Index.end(), default_random_engine());
598objects::CSeq_id_Handle& accession,
601 Uint4& sequence_length,
604std::shuffle(
m_Index.begin(),
m_Index.end(), default_random_engine());
607 if(
m_Stores[
i]->
GetIdInfo(
id, accession, gi, timestamp, sequence_length, tax_id) ) {
617std::shuffle(
m_Index.begin(),
m_Index.end(), default_random_engine());
628vector<CAsnIndex::SIndexInfo> &
info)
630std::shuffle(
m_Index.begin(),
m_Index.end(), default_random_engine());
646 for(
auto const& store:
m_Stores) {
647 count+= store->GetGiCount();
654 for(
auto const& store:
m_Stores) {
655store->EnumSeqIds(cb);
661 for(
auto const& store:
m_Stores) {
662store->EnumIndex(cb);
User-defined methods of the data storage class.
User-defined methods of the data storage class.
Contains the class definiton for CAsnCache, the main client class for accessing the ASN cache data.
CConstRef< objects::CBioseq > ExtractBioseq(CConstRef< objects::CSeq_entry > entry, const objects::CSeq_id_Handle &id)
void GetNormalizedSeqId(const objects::CSeq_id_Handle &id, string &id_str, Uint4 &version)
Berkeley BDB file cursor.
bool GetMultipleIndexEntries(const objects::CSeq_id_Handle &id, vector< CAsnIndex::SIndexInfo > &info)
void EnumSeqIds(IAsnCacheStore::TEnumSeqidCallback cb) const
CRef< objects::CSeq_entry > GetEntry(const objects::CSeq_id_Handle &id)
Check if the SeqId cache, for efficient retrieval of SeqIds, is available.
size_t GetGiCount() const
bool GetBlob(const objects::CSeq_id_Handle &id, objects::CCache_blob &blob)
Return the cache blob, packed and uninterpreted.
bool GetSeqIds(const objects::CSeq_id_Handle &id, vector< objects::CSeq_id_Handle > &all_ids, bool cheap_only)
Return the set of seq-ids associated with a given ID.
CAsnCacheStoreMany()=delete
std::vector< std::unique_ptr< IAsnCacheStore > > m_Stores
bool GetMultipleRaw(const objects::CSeq_id_Handle &id, vector< vector< unsigned char >> &buffer)
bool GetRaw(const objects::CSeq_id_Handle &id, vector< unsigned char > &buffer)
Return the raw blob in an unformatted buffer.
bool GetMultipleBlobs(const objects::CSeq_id_Handle &id, vector< CRef< objects::CCache_blob > > &blob)
bool GetIdInfo(const objects::CSeq_id_Handle &id, CAsnIndex::TGi &gi, time_t ×tamp)
Return the GI and timestamp for a given seq_id.
bool GetIndexEntry(const objects::CSeq_id_Handle &id, CAsnIndex::SIndexInfo &info)
Get the full ASN cache index entry.
std::vector< int > m_Index
void EnumIndex(IAsnCacheStore::TEnumIndexCallback cb) const
vector< CRef< objects::CSeq_entry > > GetMultipleEntries(const objects::CSeq_id_Handle &id)
std::unique_ptr< CAsnIndex > m_Index
static bool s_GetChunkAndOffset(const objects::CSeq_id_Handle &idh, CAsnIndex &index, vector< CAsnIndex::SIndexInfo > &info, bool multiple)
bool GetSeqIds(const objects::CSeq_id_Handle &id, vector< objects::CSeq_id_Handle > &all_ids, bool cheap_only)
Return the set of seq-ids associated with a given ID.
bool GetBlob(const objects::CSeq_id_Handle &id, objects::CCache_blob &blob)
Return the cache blob, packed and uninterpreted.
bool GetMultipleIndexEntries(const objects::CSeq_id_Handle &id, vector< CAsnIndex::SIndexInfo > &info)
std::unique_ptr< CChunkFile > m_CurrChunk
vector< CRef< objects::CSeq_entry > > GetMultipleEntries(const objects::CSeq_id_Handle &id)
CRef< objects::CSeq_entry > GetEntry(const objects::CSeq_id_Handle &id)
Check if the SeqId cache, for efficient retrieval of SeqIds, is available.
bool GetMultipleBlobs(const objects::CSeq_id_Handle &id, vector< CRef< objects::CCache_blob > > &blob)
size_t GetGiCount() const
std::unique_ptr< CSeqIdChunkFile > m_SeqIdChunk
CAsnIndex & x_GetIndexRef() const
bool GetMultipleRaw(const objects::CSeq_id_Handle &id, vector< vector< unsigned char >> &buffer)
bool GetIndexEntry(const objects::CSeq_id_Handle &id, CAsnIndex::SIndexInfo &info)
Get the full ASN cache index entry.
bool x_GetBlob(const CAsnIndex::SIndexInfo &info, objects::CCache_blob &blob)
std::unique_ptr< CAsnIndex > m_SeqIdIndex
void EnumIndex(IAsnCacheStore::TEnumIndexCallback cb) const
bool GetRaw(const objects::CSeq_id_Handle &id, vector< unsigned char > &buffer)
Return the raw blob in an unformatted buffer.
bool GetIdInfo(const objects::CSeq_id_Handle &id, CAsnIndex::TGi &gi, time_t ×tamp)
Return the GI and timestamp for a given seq_id.
CAsnIndex::TChunkId m_CurrChunkId
void EnumSeqIds(IAsnCacheStore::TEnumSeqidCallback cb) const
This is a simple BDB structure holding information about a given accession and its indexed location.
Berkeley DB file cursor class.
void UnPack(CSeq_entry &entry) const
std::function< void(string, uint32_t, uint64_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t)> TEnumIndexCallback
std::function< void(string, uint32_t, uint64_t, uint32_t)> TEnumSeqidCallback
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
@ eFollowLinks
Follow symbolic links.
void SetCondition(ECondition cond_from, ECondition cond_to=eNotSet)
Set search condition(type of interval)
EBDB_ErrCode Fetch(EFetchDirection fdir=eDefault)
Fetch record.
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
void Error(CExceptionArgs_Base &args)
#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 NormalizePath(const string &path, EFollowLinks follow_links=eIgnoreLinks)
Normalize a path.
static string CreateAbsolutePath(const string &path, ERelativeToWhat rtw=eRelativeToCwd)
Get an absolute path from some, possibly relative, path.
static CSeq_id_Handle GetHandle(const CSeq_id &id)
Normal way of getting a handle, works for any seq-id.
bool NotNull(void) const THROWS_NONE
Check if pointer is not null â same effect as NotEmpty().
uint32_t Uint4
4-byte (32-bit) unsigned integer
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
const TId & GetId(void) const
Get the Id member data.
list< CRef< CSeq_id > > TId
const string version
version string
const struct ncbi::grid::netcache::search::fields::SIZE size
Defines classes: CDirEntry, CFile, CDir, CSymLink, CMemoryFile, CFileUtil, CFileLock,...
static bool GetSeqId(const T &d, set< string > &labels, const string name="", bool detect=false, bool found=false)
static wxAcceleratorEntry entries[3]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4