NCBI C++ ToolKit
seq_masker_ostat_bin.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: seq_masker_ostat_bin.cpp 98105 2022-09-29 00:28:26Z morgulis $
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  * Implementation of CSeqMaskerOstatBin class.
30  *
31  */
32 
33 #include <ncbi_pch.hpp>
34 
36 
38 
39 #define STAT_FMT_COMPONENT_NAME "windowmasker-statistics-format-version"
40 #define STAT_FMT_VER_MAJOR 1
41 #define STAT_FMT_VER_MINOR 1
42 #define STAT_FMT_VER_PATCH 0
43 #define STAT_FMT_VER_PFX "binary "
44 
45 //------------------------------------------------------------------------------
52 );
53 
54 //------------------------------------------------------------------------------
56  const string & name, string const & metadata )
57  : CSeqMaskerOstat( static_cast< CNcbiOstream& >(
58  *new CNcbiOfstream( name.c_str(), IOS_BASE::binary ) ),
59  true, metadata )
60 {}
61 
62 //------------------------------------------------------------------------------
64  CNcbiOstream & os, string const & metadata )
65  : CSeqMaskerOstat( os, false, metadata )
66 { write_word( (Uint4)0 ); } // Format identifier.
67 
68 //------------------------------------------------------------------------------
70 {
71 }
72 
73 //------------------------------------------------------------------------------
75 {
76  out_stream.write( reinterpret_cast< const char * >(&word), sizeof( Uint4 ) );
77 }
78 
79 //------------------------------------------------------------------------------
81 {
82  counts.push_back( std::make_pair( unit, count ) );
83 }
84 
85 //------------------------------------------------------------------------------
87  write_word( (Uint4)3 ); // new binary id
89  write_word( (Uint4)0 ); // Format identifier.
91 
92  for( size_t i( 0 ); i < counts.size(); ++i ) {
94  write_word( counts[i].second );
95  }
96 
98  i != pvalues.end(); ++i ) {
99  write_word( *i );
100  }
101 
102  out_stream.flush();
103 }
104 
#define true
Definition: bool.h:35
#define false
Definition: bool.h:36
virtual void doFinalize()
Write data to output file.
void write_word(Uint4 word)
CSeqMaskerOstatBin(const string &name, string const &metadata)
Object constructor.
virtual void doSetUnitCount(Uint4 unit, Uint4 count)
Write count information for the unit to the binary output.
static CSeqMaskerVersion FormatVersion
Format version.
virtual ~CSeqMaskerOstatBin()
Object destructor.
Base class for computing and saving unit counts data.
Uint1 unit_size
unit size
void WriteBinMetaData(std::ostream &os) const
Write metadata in binary format.
vector< pair< Uint4, Uint4 > > counts
Unit counts.
CNcbiOstream & out_stream
Refers to the C++ stream that should be used to write out the unit counts data.
static DLIST_TYPE *DLIST_NAME() first(DLIST_LIST_TYPE *list)
Definition: dlist.tmpl.h:46
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::ofstream CNcbiOfstream
Portable alias for ofstream.
Definition: ncbistre.hpp:500
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
Definition: ncbistre.hpp:149
int i
#define STAT_FMT_COMPONENT_NAME
#define STAT_FMT_VER_MAJOR
#define STAT_FMT_VER_PFX
#define STAT_FMT_VER_PATCH
#define STAT_FMT_VER_MINOR
Modified on Tue Feb 27 05:54:57 2024 by modify_doxy.py rev. 669887