NCBI C++ ToolKit
Public Types | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
CSeqDBIdSet Class Reference

Search Toolkit Book for CSeqDBIdSet

SeqDB ID list for performing boolean set operations. More...

#include <objtools/blast/seqdb_reader/seqdbcommon.hpp>

+ Inheritance diagram for CSeqDBIdSet:
+ Collaboration diagram for CSeqDBIdSet:

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< Uint8TCounter
 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< CSeqDBGiListGetPositiveList ()
 Retrieve a positive GI list. More...
 
CRef< CSeqDBNegativeListGetNegativeList ()
 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...
 
CObjectoperator= (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_Vectorm_Ids
 Ids stored here. More...
 
CRef< CSeqDBGiListm_CachedPositive
 Cached positive list. More...
 
CRef< CSeqDBNegativeListm_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...
 

Detailed Description

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.

Member Enumeration Documentation

◆ EIdType

Type of IDs stored here.

Enumerator
eGi 
eTi 
eSi 

Definition at line 1590 of file seqdbcommon.hpp.

◆ EOperation

Types of operations that may be performed on GI lists.

Enumerator
eAnd 
eXor 
eOr 

Definition at line 1583 of file seqdbcommon.hpp.

Constructor & Destructor Documentation

◆ CSeqDBIdSet() [1/6]

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.

◆ CSeqDBIdSet() [2/6]

CSeqDBIdSet::CSeqDBIdSet ( const vector< Int4 > &  ids,
EIdType  t,
bool  positive = true 
)

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.

Parameters
idsThese IDs will be added to the list.
tThe IDs are assumed to be of this type.
positiveTrue 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().

◆ CSeqDBIdSet() [3/6]

CSeqDBIdSet::CSeqDBIdSet ( const vector< Int8 > &  ids,
EIdType  t,
bool  positive = true 
)

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.

Parameters
idsThese IDs will be added to the list.
tThe IDs are assumed to be of this type.
positiveTrue 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().

◆ CSeqDBIdSet() [4/6]

CSeqDBIdSet::CSeqDBIdSet ( const vector< Uint8 > &  ids,
EIdType  t,
bool  positive = true 
)

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.

Parameters
idsThese IDs will be added to the list.
tThe IDs are assumed to be of this type.
positiveTrue 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().

◆ CSeqDBIdSet() [5/6]

CSeqDBIdSet::CSeqDBIdSet ( const vector< TGi > &  ids,
EIdType  t,
bool  positive = true 
)

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.

Parameters
idsThese IDs will be added to the list.
tThe IDs are assumed to be of this type.
positiveTrue 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().

◆ CSeqDBIdSet() [6/6]

CSeqDBIdSet::CSeqDBIdSet ( const vector< string > &  ids,
EIdType  t,
bool  positive = true 
)

Definition at line 1912 of file seqdbcommon.cpp.

References m_Ids, CSeqDBIdSet_Vector::SetSeqIDs(), and x_SortAndUnique().

◆ ~CSeqDBIdSet()

virtual CSeqDBIdSet::~CSeqDBIdSet ( )
inlinevirtual

Virtual destructor.

Definition at line 1660 of file seqdbcommon.hpp.

Member Function Documentation

◆ Blank()

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.

Returns
True if this list is blank.

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().

◆ Compute() [1/4]

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.

Parameters
opLogical operation to perform.
idsList 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().

◆ Compute() [2/4]

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).

Parameters
opLogical operation to perform.
idsList of ids for the second argument.
positiveTrue for positive lists, false for negative.

Referenced by BOOST_AUTO_TEST_CASE().

◆ Compute() [3/4]

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).

Parameters
opLogical operation to perform.
idsList of ids for the second argument.
positiveIf true, ids represent 'negative' ids.

Definition at line 2111 of file seqdbcommon.cpp.

References m_Ids, m_Positive, positive(), result, CSeqDBIdSet_Vector::Set(), x_BooleanSetOperation(), and x_SortAndUnique().

◆ Compute() [4/4]

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).

Parameters
opLogical operation to perform.
idsList of ids for the second argument.
positiveIf true, ids represent 'negative' ids.

Definition at line 2134 of file seqdbcommon.cpp.

References m_Ids, m_Positive, positive(), result, CSeqDBIdSet_Vector::Set(), x_BooleanSetOperation(), and x_SortAndUnique().

◆ GetNegativeList()

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.

Returns
A negative GI list.

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().

◆ GetPositiveList()

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().

◆ IsPositive()

bool CSeqDBIdSet::IsPositive ( )
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().

Returns
true If the produced GI list is positive.

Definition at line 1731 of file seqdbcommon.hpp.

References m_Positive.

Referenced by BOOST_AUTO_TEST_CASE(), and CSeqDB::CSeqDB().

◆ Negate()

void CSeqDBIdSet::Negate ( )

Invert the current list.

Definition at line 1931 of file seqdbcommon.cpp.

References m_Positive.

◆ x_BooleanSetOperation()

void CSeqDBIdSet::x_BooleanSetOperation ( EOperation  op,
const vector< Int8 > &  A,
bool  A_pos,
const vector< Int8 > &  B,
bool  B_pos,
vector< Int8 > &  result,
bool result_pos 
)
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.

Parameters
opThe operation to perform (OR, AND, or XOR). [in]
AThe first input list. [in]
A_posTrue if the first list is positive. [in]
BThe second input list. [in]
B_posTrue if the second list is positive. [in]
resultThe resulting list of identifiers. [out]
result_posTrue if the result is a positive list. [out]

Definition at line 2027 of file seqdbcommon.cpp.

References result, and x_SummarizeBooleanOp().

Referenced by Compute().

◆ x_SortAndUnique() [1/2]

void CSeqDBIdSet::x_SortAndUnique ( vector< Int8 > &  ids)
staticprivate

Sort and unique the internal set.

Definition at line 1918 of file seqdbcommon.cpp.

References ct::sort().

Referenced by Compute(), and CSeqDBIdSet().

◆ x_SortAndUnique() [2/2]

void CSeqDBIdSet::x_SortAndUnique ( vector< string > &  ids)
staticprivate

Definition at line 1925 of file seqdbcommon.cpp.

References ct::sort().

◆ x_SummarizeBooleanOp()

void CSeqDBIdSet::x_SummarizeBooleanOp ( EOperation  op,
bool  A_pos,
bool  B_pos,
bool result_pos,
bool incl_A,
bool incl_B,
bool incl_AB 
)
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.

Parameters
opThe operation to perform (OR, AND, or XOR). [in]
A_posTrue if the first list is positive. [in]
B_posTrue if the second list is positive. [in]
result_posTrue if the result is a positive list. [out]
incl_ATrue if ids found only in list A are kept. [out]
incl_BTrue if ids found only in list B are kept. [out]
incl_ABTrue 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().

Member Data Documentation

◆ m_CachedNegative

CRef<CSeqDBNegativeList> CSeqDBIdSet::m_CachedNegative
private

Cached negative list.

Definition at line 1829 of file seqdbcommon.hpp.

◆ m_CachedPositive

CRef<CSeqDBGiList> CSeqDBIdSet::m_CachedPositive
private

Cached positive list.

Definition at line 1826 of file seqdbcommon.hpp.

◆ m_Ids

CRef<CSeqDBIdSet_Vector> CSeqDBIdSet::m_Ids
private

Ids stored here.

Definition at line 1823 of file seqdbcommon.hpp.

Referenced by Blank(), Compute(), CSeqDBIdSet(), GetNegativeList(), and GetPositiveList().

◆ m_IdType

EIdType CSeqDBIdSet::m_IdType
private

Id type.

Definition at line 1820 of file seqdbcommon.hpp.

Referenced by Compute(), GetNegativeList(), and GetPositiveList().

◆ m_Positive

bool CSeqDBIdSet::m_Positive
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().


The documentation for this class was generated from the following files:
Modified on Mon Jun 17 05:06:27 2024 by modify_doxy.py rev. 669887