NCBI C++ ToolKit
seq_masker_uset_hash.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: seq_masker_uset_hash.hpp 84663 2018-11-27 18:22:00Z ucko $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Author: Aleksandr Morgulis
27  *
28  * File Description:
29  * Definition for CSeqMaskerUsetHash class.
30  *
31  */
32 
33 #ifndef C_SEQ_MASKER_USET_HASH_H
34 #define C_SEQ_MASKER_USET_HASH_H
35 
36 #include <corelib/ncbitype.h>
37 #include <corelib/ncbistr.hpp>
38 #include <corelib/ncbiobj.hpp>
39 #include <corelib/ncbimisc.hpp>
40 
42 
43 /**
44  **\brief This class encapsulates the implementation of the hash
45  ** based container for unit counts.
46  **/
48 {
49  public:
50 
51  /**
52  **\brief Exceptions that CSeqMaskerUsetHash can throw.
53  **/
54  class Exception : public CException
55  {
56  public:
57 
58  enum EErrCode
59  {
60  eBadIndex /**< Bad index into the secondary table was formed. */
61  };
62 
63  /**
64  **\brief Get a description string for this exception.
65  **\return C-style description string
66  **/
67  virtual const char * GetErrCodeString() const override;
68 
70  };
71 
72  /**
73  **\brief Object constructor.
74  **/
75  CSeqMaskerUsetHash() : htp( 0 ), vtp( 0 ) {}
76 
77  /**
78  **\brief Add hash table information to the container.
79  **\param arg_k the hash key length in bits
80  **\param arg_roff the right offset of the hash key in bits
81  **\param arg_bc size of the "number of collisions" field in bits
82  **\param ht array containing the hash table
83  **/
84  void add_ht_info( Uint1 arg_k, Uint1 arg_roff, Uint1 arg_bc,
85  const Uint4 * ht );
86 
87  /**
88  **\brief Add secondary table information to the container.
89  **\param M size of the secondary table
90  **\param vt array containing the secondary table
91  **/
92  void add_vt_info( Uint4 M, const Uint2 * vt );
93 
94  /**
95  **\brief Look up the unit count in the data structure.
96  **\param unit the unit value
97  **\return the number of times the unit and its reverse complement
98  ** are present in the genome
99  **/
100  Uint4 get_info( Uint4 unit ) const;
101 
102  /**
103  **\brief Get the unit size in bases.
104  **\return the unit size
105  **/
106  Uint1 UnitSize() const { return unit_size; }
107 
108  /**
109  **\brief Set the unit size.
110  **\param us the unit size in bases
111  **/
112  void setUnitSize( Uint1 us ) { unit_size = us; }
113 
114  private:
115 
116  /**@name Provide reference semantics for CSeqMaskerUsetHash. */
117  /**@{*/
120  /**@}*/
121 
122  Uint1 unit_size; /**<\internal Unit size in bases. */
123 
124  Uint1 k; /**<\internal Hash key size in bits. */
125  Uint1 roff; /**<\internal Right offset in bits. */
126  Uint1 bc; /**<\internal Bit size of "number of collisions" field. */
127  Uint4 M; /**<\internal Size of the secondary table (in 2-byte words). */
128  Uint4 cmask; /**<\internal Mask used to extract the "number of collisions" field. */
129 
130  AutoPtr< const Uint4, ArrayDeleter< const Uint4 > > ht; /**<\internal The hash table. */
131  AutoPtr< const Uint2, ArrayDeleter< const Uint2 > > vt; /**<\internal The secondary table. */
132 
133  const Uint4 * htp; /**<\internal The actual pointer to the hash table. */
134  const Uint2 * vtp; /**<\internal The actual pointer to the secondary table. */
135 };
136 
138 
139 #endif
AutoPtr –.
Definition: ncbimisc.hpp:401
Exceptions that CSeqMaskerUsetHash can throw.
NCBI_EXCEPTION_DEFAULT(Exception, CException)
This class encapsulates the implementation of the hash based container for unit counts.
void setUnitSize(Uint1 us)
Set the unit size.
Uint1 UnitSize() const
Get the unit size in bases.
CSeqMaskerUsetHash(const CSeqMaskerUsetHash &)
CSeqMaskerUsetHash & operator=(const CSeqMaskerUsetHash &)
AutoPtr< const Uint2, ArrayDeleter< const Uint2 > > vt
CSeqMaskerUsetHash()
Object constructor.
AutoPtr< const Uint4, ArrayDeleter< const Uint4 > > ht
The NCBI C++ standard methods for dealing with std::string.
uint8_t Uint1
1-byte (8-bit) unsigned integer
Definition: ncbitype.h:99
uint32_t Uint4
4-byte (32-bit) unsigned integer
Definition: ncbitype.h:103
uint16_t Uint2
2-byte (16-bit) unsigned integer
Definition: ncbitype.h:101
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define NCBI_XALGOWINMASK_EXPORT
Definition: ncbi_export.h:1033
Miscellaneous common-use basic types and functionality.
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
Defines Limits for the types used in NCBI C/C++ toolkit.
Modified on Sun Apr 14 05:26:46 2024 by modify_doxy.py rev. 669887