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

Go to the SVN repository for this file.

1 /* $Id: seq_masker_ostat_factory.cpp 62752 2014-05-05 14:32:02Z 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 CSeqMaskerUStatFactory class.
30  *
31  */
32 
33 #include <ncbi_pch.hpp>
34 
40 
42 
43 //------------------------------------------------------------------------------
44 const char *
46 {
47  switch( GetErrCode() )
48  {
49  case eBadName: return "bad name";
50  case eCreateFail: return "creation failure";
51  default: return CException::GetErrCodeString();
52  }
53 }
54 
55 //------------------------------------------------------------------------------
57  const string & ustat_type, CNcbiOstream & os, bool use_ba,
58  string const & metadata )
59 {
60  try
61  {
62  if( ustat_type.substr( 0, 5 ) == "ascii" )
63  return new CSeqMaskerOstatAscii( os, metadata );
64  else if( ustat_type.substr( 0, 6 ) == "binary" )
65  return new CSeqMaskerOstatBin( os, metadata );
66  else if( ustat_type.substr( 0, 6 ) == "oascii" )
67  {
68  Uint4 size = atoi( ustat_type.substr( 6 ).c_str() );
69  return new CSeqMaskerOstatOptAscii( os, size, metadata );
70  }
71  else if( ustat_type.substr( 0, 7 ) == "obinary" )
72  {
73  Uint4 size = atoi( ustat_type.substr( 7 ).c_str() );
74  return new CSeqMaskerOstatOptBin( os, size, use_ba, metadata );
75  }
77  eBadName,
78  "unkown unit counts format" );
79  }
80  catch( CException & e ) {
82  "could not create a unit counts container" );
83  }
84  catch( std::exception & e )
85  {
87  eCreateFail,
88  std::string( "could not create a unit counts container" ) +
89  e.what() );
90  }
91 }
92 
93 //------------------------------------------------------------------------------
95  const string & ustat_type, const string & name, bool use_ba,
96  string const & metadata )
97 {
98  try
99  {
100  if( ustat_type.substr( 0, 5 ) == "ascii" )
101  return new CSeqMaskerOstatAscii( name, metadata );
102  else if( ustat_type.substr( 0, 6 ) == "binary" )
103  return new CSeqMaskerOstatBin( name, metadata );
104  else if( ustat_type.substr( 0, 6 ) == "oascii" )
105  {
106  Uint4 size = atoi( ustat_type.substr( 6 ).c_str() );
107  return new CSeqMaskerOstatOptAscii( name, size, metadata );
108  }
109  else if( ustat_type.substr( 0, 7 ) == "obinary" )
110  {
111  Uint4 size = atoi( ustat_type.substr( 7 ).c_str() );
112  return new CSeqMaskerOstatOptBin( name, size, use_ba, metadata );
113  }
115  eBadName,
116  "unkown unit counts format" );
117  }
118  catch( CException & e ) {
120  "could not create a unit counts container" );
121  }
122  catch( std::exception & e )
123  {
125  eCreateFail,
126  std::string( "could not create a unit counts container" ) +
127  e.what() );
128  }
129 }
130 
Class responsible for creation of unit counts statistics in text format.
Compute and save counts information in simple binary format.
Exceptions that CSeqMaskerOstatFactory might throw.
virtual const char * GetErrCodeString() const override
Get a description string for this exception.
static CSeqMaskerOstat * create(const string &ustat_type, const string &name, bool use_ba, string const &metadata="")
Method used to create a CSeqMakserOstat object by format name.
This class is responsible for saving optimized unit counts in text format.
This class is responsible for saving optimized unit counts in binary format.
Base class for computing and saving unit counts data.
string
Definition: cgiapp.hpp:690
TErrCode GetErrCode(void) const
Get error code.
Definition: ncbiexpt.cpp:453
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
Definition: ncbiexpt.hpp:704
virtual const char * GetErrCodeString(void) const
Get error code interpreted as text.
Definition: ncbiexpt.cpp:444
virtual const char * what(void) const noexcept
Standard report (includes full backlog).
Definition: ncbiexpt.cpp:342
#define NCBI_RETHROW(prev_exception, exception_class, err_code, message)
Generic macro to re-throw an exception.
Definition: ncbiexpt.hpp:737
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::ostream CNcbiOstream
Portable alias for ostream.
Definition: ncbistre.hpp:149
const struct ncbi::grid::netcache::search::fields::SIZE size
Modified on Fri Sep 20 14:57:09 2024 by modify_doxy.py rev. 669887