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

Go to the SVN repository for this file.

1 /* $Id: mask_fasta_reader.hpp 98976 2023-01-30 14:32:39Z madden $
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  * Header file for CMaskFastaReader class.
30  *
31  */
32 
33 #ifndef CMASK_FASTA_READER_H
34 #define CMASK_FASTA_READER_H
35 
37 
39 
41 
42 /**
43  **\brief Class for reading sequences from fasta files.
44  **/
46 {
47 public:
48 
49  /**
50  **\brief Object constructor.
51  **
52  **\param newInputStream input stream to read data from.
53  **\param is_nucl true if the input is DNA, false if it is protein
54  **\param parse_seqids false to disable parsing of deflines
55  **
56  **/
57  CMaskFastaReader( CNcbiIstream & newInputStream, bool is_nucl = true,
58  bool parse_seqids = false )
59  : CMaskReader( newInputStream ), is_nucleotide_(is_nucl),
60  fasta_reader_( newInputStream,
61  CONST_FLAGS |
62  (is_nucl ? objects::CFastaReader::fAssumeNuc
63  : objects::CFastaReader::fAssumeProt) |
64  (parse_seqids ? 0
65  : objects::CFastaReader::fNoParseID) )
66  {
67  if( !newInputStream && !newInputStream.eof() ) {
68  NCBI_THROW( Exception, eBadStream,
69  "bad stream state at fasta mask reader initialization" );
70  }
71  }
72 
73  /**
74  **\brief Object destructor.
75  **
76  **/
77  virtual ~CMaskFastaReader() {}
78 
79  /**
80  **\brief Read next sequence from fasta stream.
81  **
82  **\return pointer (reference counting) to the object
83  ** containing information about the sequence, or
84  ** CRef( NULL ) if end of file is reached.
85  **
86  **/
88 
89 private:
90  /** Unchaged subset of flags. */
91  static const objects::CFastaReader::TFlags CONST_FLAGS =
92  objects::CFastaReader::fForceType |
93  objects::CFastaReader::fOneSeq |
94  objects::CFastaReader::fParseRawID;
95 
96  bool is_nucleotide_; /**< This object is reading nucleotide sequences */
97 
98  objects::CFastaReader fasta_reader_; /**< Fasta reader object. */
99 };
100 
102 
103 #endif
Base class for reading FASTA sequences.
Definition: fasta.hpp:80
Class for reading sequences from fasta files.
objects::CFastaReader fasta_reader_
Fasta reader object.
CMaskFastaReader(CNcbiIstream &newInputStream, bool is_nucl=true, bool parse_seqids=false)
Object constructor.
bool is_nucleotide_
This object is reading nucleotide sequences.
virtual ~CMaskFastaReader()
Object destructor.
Exceptions thrown by CMaskReader class.
Definition: mask_reader.hpp:56
Virtual base class for all input readers.
Definition: mask_reader.hpp:50
virtual CRef< objects::CSeq_entry > GetNextSequence()=0
Read the next sequence from the source stream.
Operators to edit gaps in sequences.
#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
#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_XOBJREAD_EXPORT
Definition: ncbi_export.h:1315
Modified on Sat Jul 20 11:11:16 2024 by modify_doxy.py rev. 669887