bpp-seq  2.2.0
StreamSequenceIterator.h
Go to the documentation of this file.
1 //
2 // File: StreamSequenceIterator.h
3 // Created by: Julien Dutheil
4 // Created on: Tue Feb 26 14:27 2013
5 //
6 
7 /*
8 Copyright or © or Copr. Bio++ Development Team, (November 17, 2004)
9 
10 This software is a computer program whose purpose is to provide classes
11 for sequences analysis.
12 
13 This software is governed by the CeCILL license under French law and
14 abiding by the rules of distribution of free software. You can use,
15 modify and/ or redistribute the software under the terms of the CeCILL
16 license as circulated by CEA, CNRS and INRIA at the following URL
17 "http://www.cecill.info".
18 
19 As a counterpart to the access to the source code and rights to copy,
20 modify and redistribute granted by the license, users are provided only
21 with a limited warranty and the software's author, the holder of the
22 economic rights, and the successive licensors have only limited
23 liability.
24 
25 In this respect, the user's attention is drawn to the risks associated
26 with loading, using, modifying and/or developing or reproducing the
27 software by the user in light of its specific status of free software,
28 that may mean that it is complicated to manipulate, and that also
29 therefore means that it is reserved for developers and experienced
30 professionals having in-depth computer knowledge. Users are therefore
31 encouraged to load and test the software's suitability as regards their
32 requirements in conditions enabling the security of their systems and/or
33 data to be ensured and, more generally, to use and operate it in the
34 same conditions as regards security.
35 
36 The fact that you are presently reading this means that you have had
37 knowledge of the CeCILL license and that you accept its terms.
38 */
39 
40 #ifndef _STREAMSEQUENCEITERATOR_H_
41 #define _STREAMSEQUENCEITERATOR_H_
42 
43 #include "../SequenceIterator.h"
44 #include "ISequenceStream.h"
45 
46 // From the STL:
47 #include <istream>
48 
49 namespace bpp
50 {
51 
58  public virtual SequenceIterator
59 {
60  private:
63  std::istream* stream_;
65 
66  public:
67  StreamSequenceIterator(ISequenceStream& seqStream, std::istream& stream, const Alphabet* alphabet);
68 
70 
71  private: //Recopy is forbidden
73  alphabet_(ssi.alphabet_),
75  stream_(ssi.stream_),
76  nextSeq_(0) {}
77 
79  {
80  alphabet_ = ssi.alphabet_;
81  seqStream_ = ssi.seqStream_;
82  stream_ = ssi.stream_;
83  nextSeq_ = 0;
84  return *this;
85  }
86 
87  public:
88  virtual Sequence* nextSequence();
89 
90  virtual bool hasMoreSequences() const { return nextSeq_ != 0; }
91 };
92 
99  public virtual SequenceWithQualityIterator
100 {
101  private:
104  std::istream* stream_;
106 
107  public:
108  StreamSequenceWithQualityIterator(ISequenceStream& seqStream, std::istream& stream, const Alphabet* alphabet);
109 
111 
112  private: //Recopy is forbidden
114  alphabet_(ssi.alphabet_),
115  seqStream_(ssi.seqStream_),
116  stream_(ssi.stream_),
117  nextSeq_(0) {}
118 
120  {
121  alphabet_ = ssi.alphabet_;
122  seqStream_ = ssi.seqStream_;
123  stream_ = ssi.stream_;
124  nextSeq_ = 0;
125  return *this;
126  }
127 
128  public:
130 
131  virtual bool hasMoreSequences() const { return nextSeq_ != 0; }
132 };
133 
134 
135 } //end of namespace bpp.
136 
137 #endif //_SEQUENCEITERATOR_H_
138 
This alphabet is used to deal NumericAlphabet.
The Alphabet interface.
Definition: Alphabet.h:130
StreamSequenceWithQualityIterator(ISequenceStream &seqStream, std::istream &stream, const Alphabet *alphabet)
A SequenceWithAnnotation class with quality scores attached.
StreamSequenceIterator(ISequenceStream &seqStream, std::istream &stream, const Alphabet *alphabet)
virtual bool hasMoreSequences() const
StreamSequenceIterator(const StreamSequenceIterator &ssi)
StreamSequenceWithQualityIterator(const StreamSequenceWithQualityIterator &ssi)
virtual SequenceWithQuality * nextSequence()
A sequence iterator based on a sequence stream.
A sequence iterator based on a sequence stream.
Generic sequence iterator interface, allowing to loop over sequences.
const ISequenceStream * seqStream_
Generic sequence iterator interface, allowing to loop over sequences with quality scores...
StreamSequenceWithQualityIterator & operator=(const StreamSequenceWithQualityIterator &ssi)
A basic implementation of the Sequence interface.
Definition: Sequence.h:207
The sequence interface.
Definition: Sequence.h:74
The ISequenceStream interface.
StreamSequenceIterator & operator=(const StreamSequenceIterator &ssi)