NCBI C++ ToolKit
|
Search Toolkit Book for CSeqDBLMDB
#include <objtools/blast/seqdb_reader/impl/seqdb_lmdb.hpp>
Public Member Functions | |
CSeqDBLMDB (const string &fname) | |
virtual | ~CSeqDBLMDB () |
CSeqDBLMDB & | operator= (const CSeqDBLMDB &)=delete |
CSeqDBLMDB (const CSeqDBLMDB &)=delete | |
void | GetOids (const vector< string > &accessions, vector< blastdb::TOid > &oids) const |
Get OIDs for a vector of string accessions. More... | |
void | GetOid (const string &accession, vector< blastdb::TOid > &oids, const bool allow_dup=false) const |
Get OIDs for single string accession. More... | |
void | GetVolumesInfo (vector< string > &vol_names, vector< blastdb::TOid > &vol_num_oids) |
Return info for all volumes. More... | |
void | NegativeSeqIdsToOids (const vector< string > &ids, vector< blastdb::TOid > &rv) const |
Get Oids excluded from a vector of input accessions An oid only get exlcuded if all its seqids are found in the input list Note that the order or number of oids returned are independent of the input id list. More... | |
void | GetOidsForTaxIds (const set< TTaxId > &tax_ids, vector< blastdb::TOid > &oids, vector< TTaxId > &tax_ids_found) const |
Get Oids for Tax Ids list, idenitcal Oids are merged. More... | |
void | NegativeTaxIdsToOids (const set< TTaxId > &ids, vector< blastdb::TOid > &rv, vector< TTaxId > &tax_ids_found) const |
Get Oids to exclude for Tax ids @parm ids Input tax ids to exclude /Output tax ids found. More... | |
void | GetDBTaxIds (vector< TTaxId > &tax_ids) const |
Get All Unique Tax Ids for db @parma tax_ids Return all unique tax ids found in db. More... | |
void | GetTaxIdsForOids (const vector< blastdb::TOid > &oids, set< TTaxId > &tax_ids) const |
Get Tax Ids for oid list. More... | |
Public Member Functions inherited from CObject | |
CObject (void) | |
Constructor. More... | |
CObject (const CObject &src) | |
Copy constructor. More... | |
virtual | ~CObject (void) |
Destructor. More... | |
CObject & | operator= (const CObject &src) THROWS_NONE |
Assignment operator. More... | |
bool | CanBeDeleted (void) const THROWS_NONE |
Check if object can be deleted. More... | |
bool | IsAllocatedInPool (void) const THROWS_NONE |
Check if object is allocated in memory pool (not system heap) More... | |
bool | Referenced (void) const THROWS_NONE |
Check if object is referenced. More... | |
bool | ReferencedOnlyOnce (void) const THROWS_NONE |
Check if object is referenced only once. More... | |
void | AddReference (void) const |
Add reference to object. More... | |
void | RemoveReference (void) const |
Remove reference to object. More... | |
void | ReleaseReference (void) const |
Remove reference without deleting object. More... | |
virtual void | DoNotDeleteThisObject (void) |
Mark this object as not allocated in heap – do not delete this object. More... | |
virtual void | DoDeleteThisObject (void) |
Mark this object as allocated in heap – object can be deleted. More... | |
void * | operator new (size_t size) |
Define new operator for memory allocation. More... | |
void * | operator new[] (size_t size) |
Define new[] operator for 'array' memory allocation. More... | |
void | operator delete (void *ptr) |
Define delete operator for memory deallocation. More... | |
void | operator delete[] (void *ptr) |
Define delete[] operator for memory deallocation. More... | |
void * | operator new (size_t size, void *place) |
Define new operator. More... | |
void | operator delete (void *ptr, void *place) |
Define delete operator. More... | |
void * | operator new (size_t size, CObjectMemoryPool *place) |
Define new operator using memory pool. More... | |
void | operator delete (void *ptr, CObjectMemoryPool *place) |
Define delete operator. More... | |
virtual void | DebugDump (CDebugDumpContext ddc, unsigned int depth) const |
Define method for dumping debug information. More... | |
Public Member Functions inherited from CDebugDumpable | |
CDebugDumpable (void) | |
virtual | ~CDebugDumpable (void) |
void | DebugDumpText (ostream &out, const string &bundle, unsigned int depth) const |
void | DebugDumpFormat (CDebugDumpFormatter &ddf, const string &bundle, unsigned int depth) const |
void | DumpToConsole (void) const |
Private Attributes | |
string | m_LMDBFile |
string | m_Oid2SeqIdsFile |
string | m_Oid2TaxIdsFile |
string | m_TaxId2OidsFile |
string | m_TaxId2OffsetsFile |
bool | m_LMDBFileOpened |
blastdb::TOid | m_NumOids |
Additional Inherited Members | |
Public Types inherited from CObject | |
enum | EAllocFillMode { eAllocFillNone = 1 , eAllocFillZero , eAllocFillPattern } |
Control filling of newly allocated memory. More... | |
typedef CObjectCounterLocker | TLockerType |
Default locker type for CRef. More... | |
typedef atomic< Uint8 > | TCounter |
Counter type is CAtomiCounter. More... | |
typedef Uint8 | TCount |
Alias for value type of counter. More... | |
Static Public Member Functions inherited from CObject | |
static NCBI_XNCBI_EXPORT void | ThrowNullPointerException (void) |
Define method to throw null pointer exception. More... | |
static NCBI_XNCBI_EXPORT void | ThrowNullPointerException (const type_info &type) |
static EAllocFillMode | GetAllocFillMode (void) |
static void | SetAllocFillMode (EAllocFillMode mode) |
static void | SetAllocFillMode (const string &value) |
Set mode from configuration parameter value. More... | |
Static Public Member Functions inherited from CDebugDumpable | |
static void | EnableDebugDump (bool on) |
Static Public Attributes inherited from CObject | |
static const TCount | eCounterBitsCanBeDeleted = 1 << 0 |
Define possible object states. More... | |
static const TCount | eCounterBitsInPlainHeap = 1 << 1 |
Heap signature was found. More... | |
static const TCount | eCounterBitsPlaceMask |
Mask for 'in heap' state flags. More... | |
static const int | eCounterStep = 1 << 2 |
Skip over the "in heap" bits. More... | |
static const TCount | eCounterValid = TCount(1) << (sizeof(TCount) * 8 - 2) |
Minimal value for valid objects (reference counter is zero) Must be a single bit value. More... | |
static const TCount | eCounterStateMask |
Valid object, and object in heap. More... | |
Protected Member Functions inherited from CObject | |
virtual void | DeleteThis (void) |
Virtual method "deleting" this object. More... | |
Definition at line 43 of file seqdb_lmdb.hpp.
Definition at line 242 of file seqdb_lmdb.cpp.
|
virtual |
Definition at line 253 of file seqdb_lmdb.cpp.
References CBlastLMDBManager::CloseEnv(), CBlastLMDBManager::GetInstance(), m_LMDBFile, and m_LMDBFileOpened.
|
delete |
void CSeqDBLMDB::GetDBTaxIds | ( | vector< TTaxId > & | tax_ids | ) | const |
Get All Unique Tax Ids for db @parma tax_ids Return all unique tax ids found in db.
Definition at line 558 of file seqdb_lmdb.cpp.
References lmdb::txn::begin(), CBlastLMDBManager::CloseEnv(), lmdb::error::code(), dbname(), env, CSeqDB_Path::FindBaseName(), CBlastLMDBManager::GetInstance(), CBlastLMDBManager::GetReadEnvTax(), CSeqDB_Substring::GetString(), ncbi::grid::netcache::search::fields::key, m_TaxId2OffsetsFile, MDB_NEXT, MDB_NOTFOUND, MDB_RDONLY, NCBI_THROW, lmdb::cursor::open(), and TAX_ID_FROM.
Referenced by CSeqDBLMDBEntry::GetDBTaxIds().
void CSeqDBLMDB::GetOid | ( | const string & | accession, |
vector< blastdb::TOid > & | oids, | ||
const bool | allow_dup = false |
||
) | const |
Get OIDs for single string accession.
String accession may have ".version" appended. If there are no matches, oids will be returned empty. If there are multiple matches, and allow_dup is true,
accession | String accession (with or without version suffix) [in] |
oids | Reference to vector of TOid to receive found OIDs [out] |
allow_dup | If true, return all OIDs which match (default false) [in] |
Definition at line 262 of file seqdb_lmdb.cpp.
References lmdb::txn::begin(), CBlastLMDBManager::CloseEnv(), lmdb::error::code(), dbname(), env, CSeqDB_Path::FindBaseName(), CBlastLMDBManager::GetInstance(), CBlastLMDBManager::GetReadEnvAcc(), CSeqDB_Substring::GetString(), m_LMDBFile, m_LMDBFileOpened, MDB_GET_CURRENT, MDB_NEXT_DUP, MDB_NOTFOUND, MDB_RDONLY, MDB_SET, NCBI_THROW, lmdb::cursor::open(), and val.
Referenced by CSeqDBLMDBEntry::AccessionToOids().
void CSeqDBLMDB::GetOids | ( | const vector< string > & | accessions, |
vector< blastdb::TOid > & | oids | ||
) | const |
Get OIDs for a vector of string accessions.
Accessions may have ".version" appended. Returned vector of OIDs will have the same length as vector of accessions in one-to-one correspondence. Any accessions which are not found will be assigned OIDs of kSeqDBEntryNotFound (-1).
accessions | Vector of string accessions [in] |
oids | Reference to vector of TOid to receive found OIDs [out] |
Definition at line 360 of file seqdb_lmdb.cpp.
References lmdb::txn::begin(), CBlastLMDBManager::CloseEnv(), lmdb::error::code(), dbname(), env, CSeqDB_Path::FindBaseName(), CBlastLMDBManager::GetInstance(), CBlastLMDBManager::GetReadEnvAcc(), CSeqDB_Substring::GetString(), i, kSeqDBEntryNotFound, m_LMDBFile, m_LMDBFileOpened, MDB_GET_CURRENT, MDB_NOTFOUND, MDB_RDONLY, MDB_SET, NCBI_THROW, lmdb::cursor::open(), and val.
Referenced by CSeqDBLMDBEntry::AccessionsToOids(), BOOST_AUTO_TEST_CASE(), and NegativeSeqIdsToOids().
void CSeqDBLMDB::GetOidsForTaxIds | ( | const set< TTaxId > & | tax_ids, |
vector< blastdb::TOid > & | oids, | ||
vector< TTaxId > & | tax_ids_found | ||
) | const |
Get Oids for Tax Ids list, idenitcal Oids are merged.
tax_ids | Input tax ids /Output tax ids found |
oids | Oids found for input tax ids |
Definition at line 591 of file seqdb_lmdb.cpp.
References lmdb::txn::begin(), CBlastLMDBManager::CloseEnv(), lmdb::error::code(), count, dbname(), env, CSeqDB_Path::FindBaseName(), CBlastLMDBManager::GetInstance(), CMemoryFile::GetPtr(), CBlastLMDBManager::GetReadEnvTax(), CSeqDB_Substring::GetString(), i, ITERATE, log, m_NumOids, m_TaxId2OffsetsFile, m_TaxId2OidsFile, MDB_GET_CURRENT, MDB_NEXT_DUP, MDB_NOTFOUND, MDB_RDONLY, MDB_SET, NCBI_THROW, offsets, lmdb::cursor::open(), ct::sort(), TAX_ID_TO, and val.
Referenced by BOOST_AUTO_TEST_CASE(), NegativeTaxIdsToOids(), and CSeqDBLMDBEntry::TaxIdsToOids().
void CSeqDBLMDB::GetTaxIdsForOids | ( | const vector< blastdb::TOid > & | oids, |
set< TTaxId > & | tax_ids | ||
) | const |
Get Tax Ids for oid list.
oids | Input oid list |
tax_ids | Output tax id list |
Definition at line 737 of file seqdb_lmdb.cpp.
References i, set< Key, Compare >::insert(), lookup(), and m_Oid2TaxIdsFile.
Referenced by CSeqDBLMDBEntry::GetTaxIdsForOids().
void CSeqDBLMDB::GetVolumesInfo | ( | vector< string > & | vol_names, |
vector< blastdb::TOid > & | vol_num_oids | ||
) |
Return info for all volumes.
vol_names | Reference to vector to receive volume names [out] |
vol_num_oids | Reference to vector to receive number of OIDs in each volume [out] |
Definition at line 306 of file seqdb_lmdb.cpp.
References lmdb::txn::begin(), CBlastLMDBManager::CloseEnv(), lmdb::dbi_stat(), env, CBlastLMDBManager::GetInstance(), CBlastLMDBManager::GetReadEnvVol(), i, m_LMDBFile, m_NumOids, MDB_GET_CURRENT, MDB_RDONLY, MDB_SET, MDB_stat::ms_entries, NCBI_THROW, lmdb::cursor::open(), and val.
Referenced by BOOST_AUTO_TEST_CASE(), and CSeqDBLMDBEntry::CSeqDBLMDBEntry().
void CSeqDBLMDB::NegativeSeqIdsToOids | ( | const vector< string > & | ids, |
vector< blastdb::TOid > & | rv | ||
) | const |
Get Oids excluded from a vector of input accessions An oid only get exlcuded if all its seqids are found in the input list Note that the order or number of oids returned are independent of the input id list.
ids | Accessions to exclude |
rv | Oids that are excluded |
Definition at line 515 of file seqdb_lmdb.cpp.
References SOidSeqIdPair::cmp_oid(), GetOids(), i, kSeqDBEntryNotFound, lookup(), m_Oid2SeqIdsFile, s_CompareIdList(), and ct::sort().
Referenced by BOOST_AUTO_TEST_CASE(), and CSeqDBLMDBEntry::NegativeSeqIdsToOids().
void CSeqDBLMDB::NegativeTaxIdsToOids | ( | const set< TTaxId > & | ids, |
vector< blastdb::TOid > & | rv, | ||
vector< TTaxId > & | tax_ids_found | ||
) | const |
Get Oids to exclude for Tax ids @parm ids Input tax ids to exclude /Output tax ids found.
rv | Oids to exclude based on input tax id list |
Definition at line 709 of file seqdb_lmdb.cpp.
References set< Key, Compare >::end(), set< Key, Compare >::find(), GetOidsForTaxIds(), i, lookup(), m_Oid2TaxIdsFile, and set< Key, Compare >::size().
Referenced by BOOST_AUTO_TEST_CASE(), and CSeqDBLMDBEntry::NegativeTaxIdsToOids().
|
delete |
|
private |
Definition at line 103 of file seqdb_lmdb.hpp.
Referenced by GetOid(), GetOids(), GetVolumesInfo(), and ~CSeqDBLMDB().
|
mutableprivate |
Definition at line 108 of file seqdb_lmdb.hpp.
Referenced by GetOid(), GetOids(), and ~CSeqDBLMDB().
|
private |
Definition at line 109 of file seqdb_lmdb.hpp.
Referenced by GetOidsForTaxIds(), and GetVolumesInfo().
|
private |
Definition at line 104 of file seqdb_lmdb.hpp.
Referenced by NegativeSeqIdsToOids().
|
private |
Definition at line 105 of file seqdb_lmdb.hpp.
Referenced by GetTaxIdsForOids(), and NegativeTaxIdsToOids().
|
private |
Definition at line 107 of file seqdb_lmdb.hpp.
Referenced by GetDBTaxIds(), and GetOidsForTaxIds().
|
private |
Definition at line 106 of file seqdb_lmdb.hpp.
Referenced by GetOidsForTaxIds().