NCBI C++ ToolKit
|
Search Toolkit Book for CSeqDBIdSet
SeqDB ID list for performing boolean set operations. More...
#include <objtools/blast/seqdb_reader/seqdbcommon.hpp>
Public Types | |
enum | EOperation { eAnd , eXor , eOr } |
Types of operations that may be performed on GI lists. More... | |
enum | EIdType { eGi , eTi , eSi } |
Type of IDs stored here. More... | |
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... | |
Public Member Functions | |
CSeqDBIdSet () | |
Construct a 'blank' CSeqDBIdSet object. More... | |
CSeqDBIdSet (const vector< Int4 > &ids, EIdType t, bool positive=true) | |
Build a computed ID list given an initial set of IDs. More... | |
CSeqDBIdSet (const vector< Int8 > &ids, EIdType t, bool positive=true) | |
Build a computed ID list given an initial set of IDs. More... | |
CSeqDBIdSet (const vector< Uint8 > &ids, EIdType t, bool positive=true) | |
Build a computed ID list given an initial set of IDs. More... | |
CSeqDBIdSet (const vector< TGi > &ids, EIdType t, bool positive=true) | |
Build a computed ID list given an initial set of IDs. More... | |
CSeqDBIdSet (const vector< string > &ids, EIdType t, bool positive=true) | |
virtual | ~CSeqDBIdSet () |
Virtual destructor. More... | |
void | Negate () |
Invert the current list. More... | |
void | Compute (EOperation op, const vector< int > &ids, bool positive=true) |
Perform a logical operation on a list. More... | |
void | Compute (EOperation op, const vector< Int8 > &ids, bool positive=true) |
Perform a logical operation on a list. More... | |
void | Compute (EOperation op, const vector< Uint8 > &ids, bool positive=true) |
Perform a logical operation on a list. More... | |
void | Compute (EOperation op, const CSeqDBIdSet &ids) |
Perform a logical operation on a list. More... | |
bool | IsPositive () |
Checks whether a positive GI list was produced. More... | |
CRef< CSeqDBGiList > | GetPositiveList () |
Retrieve a positive GI list. More... | |
CRef< CSeqDBNegativeList > | GetNegativeList () |
Retrieve a negative GI list. More... | |
bool | Blank () const |
Check if an ID list is blank. 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 Member Functions | |
void | x_BooleanSetOperation (EOperation op, const vector< Int8 > &A, bool A_pos, const vector< Int8 > &B, bool B_pos, vector< Int8 > &result, bool &result_pos) |
Compute boolean operation on two vectors. More... | |
Static Private Member Functions | |
static void | x_SortAndUnique (vector< Int8 > &ids) |
Sort and unique the internal set. More... | |
static void | x_SortAndUnique (vector< string > &ids) |
static void | x_SummarizeBooleanOp (EOperation op, bool A_pos, bool B_pos, bool &result_pos, bool &incl_A, bool &incl_B, bool &incl_AB) |
Compute inclusion flags for a boolean operation. More... | |
Private Attributes | |
bool | m_Positive |
True if the current list is positive. More... | |
EIdType | m_IdType |
Id type. More... | |
CRef< CSeqDBIdSet_Vector > | m_Ids |
Ids stored here. More... | |
CRef< CSeqDBGiList > | m_CachedPositive |
Cached positive list. More... | |
CRef< CSeqDBNegativeList > | m_CachedNegative |
Cached negative list. More... | |
Additional Inherited Members | |
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... | |
SeqDB ID list for performing boolean set operations.
This class permits boolean operations on lists of numeric IDs, and can be passed to CSeqDB in the same way as a CSeqDBGiList. CSeqDBGiList or CSeqDBNegativeList objects can be constructed as well. Logical operations supported include AND, OR, XOR, and NOT. Internally this uses a CRef based copy-on-write scheme, so these objects can be copied in constant time.
Definition at line 1580 of file seqdbcommon.hpp.
enum CSeqDBIdSet::EIdType |
Types of operations that may be performed on GI lists.
Enumerator | |
---|---|
eAnd | |
eXor | |
eOr |
Definition at line 1583 of file seqdbcommon.hpp.
CSeqDBIdSet::CSeqDBIdSet | ( | ) |
Construct a 'blank' CSeqDBIdSet object.
This produces a blank ID set object, which (if applied) would not cause any filtering to occur. This is represented here as a negative ID list with no elements.
Definition at line 2243 of file seqdbcommon.cpp.
Build a computed ID list given an initial set of IDs.
This initializes a list with an initial set of IDs of the specified type. All further logic operations on the list should use vectors of IDs or CSeqDBIdSet objects initialized with the same EIdType enumeration.
ids | These IDs will be added to the list. |
t | The IDs are assumed to be of this type. |
positive | True for a positive ID list, false for negative. |
Definition at line 1886 of file seqdbcommon.cpp.
References m_Ids, CSeqDBIdSet_Vector::Set(), and x_SortAndUnique().
Build a computed ID list given an initial set of IDs.
This initializes a list with an initial set of IDs of the specified type. All further logic operations on the list should use vectors of IDs or CSeqDBIdSet objects initialized with the same EIdType enumeration.
ids | These IDs will be added to the list. |
t | The IDs are assumed to be of this type. |
positive | True for a positive ID list, false for negative. |
Definition at line 1892 of file seqdbcommon.cpp.
References m_Ids, CSeqDBIdSet_Vector::Set(), and x_SortAndUnique().
Build a computed ID list given an initial set of IDs.
This initializes a list with an initial set of IDs of the specified type. All further logic operations on the list should use vectors of IDs or CSeqDBIdSet objects initialized with the same EIdType enumeration.
ids | These IDs will be added to the list. |
t | The IDs are assumed to be of this type. |
positive | True for a positive ID list, false for negative. |
Definition at line 1898 of file seqdbcommon.cpp.
References m_Ids, CSeqDBIdSet_Vector::Set(), and x_SortAndUnique().
Build a computed ID list given an initial set of IDs.
This initializes a list with an initial set of IDs of the specified type. All further logic operations on the list should use vectors of IDs or CSeqDBIdSet objects initialized with the same EIdType enumeration.
ids | These IDs will be added to the list. |
t | The IDs are assumed to be of this type. |
positive | True for a positive ID list, false for negative. |
Definition at line 1905 of file seqdbcommon.cpp.
References m_Ids, CSeqDBIdSet_Vector::Set(), and x_SortAndUnique().
Definition at line 1912 of file seqdbcommon.cpp.
References m_Ids, CSeqDBIdSet_Vector::SetSeqIDs(), and x_SortAndUnique().
|
inlinevirtual |
Virtual destructor.
Definition at line 1660 of file seqdbcommon.hpp.
bool CSeqDBIdSet::Blank | ( | ) | const |
Check if an ID list is blank.
An ID list is considered 'blank' iff it is a negative list with no elements. Constructing a database with such a list is equivalent to not specifying a list. Blank lists are produced by the default constructor, by specifying a negative list and providing an empty vector, or by computation (an intersection of disjoint negative lists, for example). This method returns true in those cases; otherwise it returns false.
Definition at line 2250 of file seqdbcommon.cpp.
References m_Ids, m_Positive, and CSeqDBIdSet_Vector::Size().
Referenced by BOOST_AUTO_TEST_CASE(), CSeqDB::CSeqDB(), s_SeqDbGetSequence(), and CSeqDBImpl::x_InitIdSet().
void CSeqDBIdSet::Compute | ( | EOperation | op, |
const CSeqDBIdSet & | ids | ||
) |
Perform a logical operation on a list.
The logical operation is performed between the current list and the ids parameter. For example if 'eOr' is specified, the operation performed will be 'X OR Y'. The 'ids' list will not be modified by this operation.
op | Logical operation to perform. |
ids | List of ids for the second argument. |
Definition at line 2157 of file seqdbcommon.cpp.
References CSeqDBIdSet_Vector::Get(), m_Ids, m_IdType, m_Positive, NCBI_THROW, result, CSeqDBIdSet_Vector::Set(), and x_BooleanSetOperation().
void CSeqDBIdSet::Compute | ( | EOperation | op, |
const vector< int > & | ids, | ||
bool | positive = true |
||
) |
Perform a logical operation on a list.
The logical operation is performed between the current list and the ids parameter, and the 'positive' flag is used to determine if the new input list should be treated as a positive or negative list. For example, using op == eOr and positive == false would perform the operation (X OR NOT Y).
op | Logical operation to perform. |
ids | List of ids for the second argument. |
positive | True for positive lists, false for negative. |
Referenced by BOOST_AUTO_TEST_CASE().
void CSeqDBIdSet::Compute | ( | EOperation | op, |
const vector< Int8 > & | ids, | ||
bool | positive = true |
||
) |
Perform a logical operation on a list.
The logical operation is performed between the current list and the ids parameter, and the 'positive' flag is used to determine if the new input list should be treated as a positive or negative list. For example, using op == eOr and positive == false would perform the operation (X OR NOT Y).
op | Logical operation to perform. |
ids | List of ids for the second argument. |
positive | If true, ids represent 'negative' ids. |
Definition at line 2111 of file seqdbcommon.cpp.
References B, m_Ids, m_Positive, positive(), result, CSeqDBIdSet_Vector::Set(), x_BooleanSetOperation(), and x_SortAndUnique().
void CSeqDBIdSet::Compute | ( | EOperation | op, |
const vector< Uint8 > & | ids, | ||
bool | positive = true |
||
) |
Perform a logical operation on a list.
The logical operation is performed between the current list and the ids parameter, and the 'positive' flag is used to determine if the new input list should be treated as a positive or negative list. For example, using op == eOr and positive == false would perform the operation (X OR NOT Y).
op | Logical operation to perform. |
ids | List of ids for the second argument. |
positive | If true, ids represent 'negative' ids. |
Definition at line 2134 of file seqdbcommon.cpp.
References B, m_Ids, m_Positive, positive(), result, CSeqDBIdSet_Vector::Set(), x_BooleanSetOperation(), and x_SortAndUnique().
CRef< CSeqDBNegativeList > CSeqDBIdSet::GetNegativeList | ( | ) |
Retrieve a negative GI list.
If IsPositive() returned false, this method should be used to retrieve a positive GI list. If IsPositive() returned true, this method will throw an exception.
Definition at line 2208 of file seqdbcommon.cpp.
References _ASSERT, CSeqDBNegativeList::AddGi(), CSeqDBNegativeList::AddSi(), CSeqDBNegativeList::AddTi(), eGi, eTi, GI_FROM, ITERATE, m_Ids, m_IdType, m_Positive, NCBI_THROW, CSeqDBNegativeList::ReserveGis(), CSeqDBNegativeList::ReserveSis(), CSeqDBNegativeList::ReserveTis(), CSeqDBIdSet_Vector::Set(), CSeqDBIdSet_Vector::SetSeqIDs(), and CSeqDBIdSet_Vector::Size().
Referenced by BOOST_AUTO_TEST_CASE(), CSeqDB::CSeqDB(), and CBlastKmerThread::Main().
CRef< CSeqDBGiList > CSeqDBIdSet::GetPositiveList | ( | ) |
Retrieve a positive GI list.
If IsPositive() returned true, this method should be used to retrieve a positive GI list. If IsPositive() returned false, this method will throw an exception.
Definition at line 2180 of file seqdbcommon.cpp.
References _ASSERT, CSeqDBGiList::AddGi(), CSeqDBGiList::AddTi(), eTi, GI_FROM, ITERATE, m_Ids, m_IdType, m_Positive, NCBI_THROW, CSeqDBGiList::ReserveGis(), CSeqDBGiList::ReserveTis(), CSeqDBIdSet_Vector::Set(), and CSeqDBIdSet_Vector::Size().
Referenced by BOOST_AUTO_TEST_CASE(), and CSeqDB::CSeqDB().
|
inline |
Checks whether a positive GI list was produced.
If this method returns true, a positive list was produced, and can be retrieved with GetPositiveList(). If it returns false, a negative list was produced and can be retrieved with GetNegativeList().
Definition at line 1731 of file seqdbcommon.hpp.
References m_Positive.
Referenced by BOOST_AUTO_TEST_CASE(), and CSeqDB::CSeqDB().
void CSeqDBIdSet::Negate | ( | ) |
|
private |
Compute boolean operation on two vectors.
This takes a logical operator (AND, OR, or XOR) and two positive or negative lists, and produces a positive or negative list representing that operation applied to those lists.
op | The operation to perform (OR, AND, or XOR). [in] |
A | The first input list. [in] |
A_pos | True if the first list is positive. [in] |
B | The second input list. [in] |
B_pos | True if the second list is positive. [in] |
result | The resulting list of identifiers. [out] |
result_pos | True if the result is a positive list. [out] |
Definition at line 2027 of file seqdbcommon.cpp.
References A, B, Bx, result, and x_SummarizeBooleanOp().
Referenced by Compute().
|
staticprivate |
Sort and unique the internal set.
Definition at line 1918 of file seqdbcommon.cpp.
References ct::sort().
Referenced by Compute(), and CSeqDBIdSet().
|
staticprivate |
Definition at line 1925 of file seqdbcommon.cpp.
References ct::sort().
|
staticprivate |
Compute inclusion flags for a boolean operation.
This takes a logical operator (AND, OR, or XOR) and a flag indicating whether each input lists is positive or negative, and produces a flag indicating whether the resulting list will be positive or negative and three flags used to control the set merging operation.
op | The operation to perform (OR, AND, or XOR). [in] |
A_pos | True if the first list is positive. [in] |
B_pos | True if the second list is positive. [in] |
result_pos | True if the result is a positive list. [out] |
incl_A | True if ids found only in list A are kept. [out] |
incl_B | True if ids found only in list B are kept. [out] |
incl_AB | True if ids found in both lists are kept. [out] |
Definition at line 1936 of file seqdbcommon.cpp.
References _ASSERT, eAnd, eOr, and eXor.
Referenced by x_BooleanSetOperation().
|
private |
Cached negative list.
Definition at line 1829 of file seqdbcommon.hpp.
|
private |
Cached positive list.
Definition at line 1826 of file seqdbcommon.hpp.
|
private |
Ids stored here.
Definition at line 1823 of file seqdbcommon.hpp.
Referenced by Blank(), Compute(), CSeqDBIdSet(), GetNegativeList(), and GetPositiveList().
|
private |
Id type.
Definition at line 1820 of file seqdbcommon.hpp.
Referenced by Compute(), GetNegativeList(), and GetPositiveList().
|
private |
True if the current list is positive.
Definition at line 1817 of file seqdbcommon.hpp.
Referenced by Blank(), Compute(), GetNegativeList(), GetPositiveList(), IsPositive(), and Negate().