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

Go to the SVN repository for this file.

1 /* $Id: seq_masker_istat_obinary.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 CSeqMaskerIstatOBinary class.
30  *
31  */
32 
33 #ifndef C_SEQ_MASKER_ISTAT_OBINARY_H
34 #define C_SEQ_MASKER_ISTAT_OBINARY_H
35 
36 #include <corelib/ncbitype.h>
37 #include <corelib/ncbistr.hpp>
38 #include <corelib/ncbiobj.hpp>
39 
42 
44 
45 /**
46  **\brief Read counts information from a binary file in optimized format.
47  **/
49  : public CSeqMaskerIstat
50 {
51  public:
52 
53  /**
54  **\brief Exceptions that CSeqMaskerIstatOBinary might throw.
55  **/
56  class Exception : public CException
57  {
58  public:
59 
60  enum EErrCode
61  {
62  eStreamOpenFail, /**< File open failure. */
63  eBadHashParam, /**< Bad hash parameter. */
64  eBadParam, /**< Bad parameter. */
65  eFormat, /**< File does not follow the format spec. */
66  eAlloc /**< Allocation failure. */
67  };
68 
69  /**
70  **\brief Get a description string for this exception.
71  **\return C-style description string
72  **/
73  virtual const char * GetErrCodeString() const override;
74 
76  };
77 
78  /**
79  **\brief Object constructor.
80  **
81  ** arg_threshold, arg_textend, arg_max_count, and arg_min_count, if
82  ** non zero, override the values in the input file.
83  **
84  **\param name file name
85  **\param arg_threshold T_threshold
86  **\param arg_textend T_extend
87  **\param arg_max_count T_high
88  **\param arg_use_max_count value to use for units with count > T_high
89  **\param arg_min_count T_low
90  **\param arg_use_min_count value to use for units with count < T_low
91  **\param arg_use_ba use bit array optimization if available
92  **\param skip skip this many bytes in the beginning
93  **/
94  explicit CSeqMaskerIstatOBinary( const string & name,
95  Uint4 arg_threshold,
96  Uint4 arg_textend,
97  Uint4 arg_max_count,
98  Uint4 arg_use_max_count,
99  Uint4 arg_min_count,
100  Uint4 arg_use_min_count,
101  bool arg_use_ba,
102  Uint4 skip = 0 );
103 
104  /**
105  **\brief Object destructor.
106  **/
108 
109  /**
110  **\brief Get the value of the unit size
111  **\return unit size
112  **/
113  virtual Uint1 UnitSize() const { return uset.UnitSize(); }
114 
115  protected:
116 
117  /**
118  **\brief Get the count of the given unit.
119  **\param unit the unit to look up
120  **\return the count value for the unit
121  **/
122  virtual Uint4 at( Uint4 unit ) const;
123 
124  /**
125  \brief Get the true count for an n-mer.
126 
127  \param unit the n-mer value
128 
129  \return n-mer count not corrected for t_low
130  and t_high values
131  **/
132  virtual Uint4 trueat( Uint4 unit ) const;
133 
134  private:
135 
136  /**\internal
137  **\brief Read a 4-byte unsigned integer from a binary stream.
138  **\param is the input stream
139  **\return 4 byte unsigned integer read from is
140  **/
141  Uint4 readWord( CNcbiIstream & is ) const;
142 
143  /**\internal
144  **\brief The unit counts container.
145  **/
147 };
148 
150 
151 #endif
Exceptions that CSeqMaskerIstatOBinary might throw.
@ eFormat
File does not follow the format spec.
NCBI_EXCEPTION_DEFAULT(Exception, CException)
Read counts information from a binary file in optimized format.
virtual Uint1 UnitSize() const
Get the value of the unit size.
virtual ~CSeqMaskerIstatOBinary()
Object destructor.
Defines an interface for accessing the unit counts information.
virtual Uint4 trueat(Uint4 unit) const =0
Get the true count for an n-mer.
virtual Uint4 at(Uint4 unit) const =0
Get the unit count of a given unit.
This class encapsulates the implementation of the hash based container for unit counts.
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
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
IO_PREFIX::istream CNcbiIstream
Portable alias for istream.
Definition: ncbistre.hpp:146
#define NCBI_XALGOWINMASK_EXPORT
Definition: ncbi_export.h:1033
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 Wed Apr 17 13:10:40 2024 by modify_doxy.py rev. 669887