A library for working with phylogenetic and population genetic data.
v0.27.0
fasta_output_iterator.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_SEQUENCE_FORMATS_FASTA_OUTPUT_ITERATOR_H_
2 #define GENESIS_SEQUENCE_FORMATS_FASTA_OUTPUT_ITERATOR_H_
3 
4 /*
5  Genesis - A toolkit for working with phylogenetic data.
6  Copyright (C) 2014-2020 Lucas Czech and HITS gGmbH
7 
8  This program is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program. If not, see <http://www.gnu.org/licenses/>.
20 
21  Contact:
22  Lucas Czech <lucas.czech@h-its.org>
23  Exelixis Lab, Heidelberg Institute for Theoretical Studies
24  Schloss-Wolfsbrunnenweg 35, D-69118 Heidelberg, Germany
25 */
26 
36 
38 
39 #include <iterator>
40 #include <iostream>
41 
42 namespace genesis {
43 namespace sequence {
44 
45 // =================================================================================================
46 // Fasta Output Iterator
47 // =================================================================================================
48 
67 {
68 public:
69 
70  // -------------------------------------------------------------------------
71  // Member Types
72  // -------------------------------------------------------------------------
73 
75 
76  // -------------------------------------------------------------------------
77  // Constructors and Rule of Five
78  // -------------------------------------------------------------------------
79 
80  FastaOutputIterator() = delete;
81 
82  explicit FastaOutputIterator( std::shared_ptr<utils::BaseOutputTarget> target )
83  : target_( target )
84  , writer_()
85  {}
86 
87  FastaOutputIterator( std::shared_ptr<utils::BaseOutputTarget> target, FastaWriter const& writer )
88  : target_( target )
89  , writer_( writer )
90  {}
91 
92  ~FastaOutputIterator() = default;
93 
94  FastaOutputIterator( self_type const& ) = default;
95  FastaOutputIterator( self_type&& ) = default;
96 
97  self_type& operator= ( self_type const& ) = default;
98  self_type& operator= ( self_type&& ) = default;
99 
100  // -------------------------------------------------------------------------
101  // Accessors
102  // -------------------------------------------------------------------------
103 
105  {
106  writer_.write( seq, target_ );
107  return *this;
108  }
109 
117  {
118  return writer_;
119  }
120 
121  // -------------------------------------------------------------------------
122  // Data Members
123  // -------------------------------------------------------------------------
124 
125 private:
126 
127  std::shared_ptr<utils::BaseOutputTarget> target_;
128  FastaWriter writer_;
129 };
130 
131 } // namespace sequence
132 } // namespace genesis
133 
134 #endif // include guard
genesis::sequence::FastaOutputIterator::~FastaOutputIterator
~FastaOutputIterator()=default
genesis::sequence::FastaOutputIterator::FastaOutputIterator
FastaOutputIterator()=delete
genesis::sequence::FastaOutputIterator::writer
FastaWriter & writer()
Return the FastaWriter used for this iterator.
Definition: fasta_output_iterator.hpp:116
genesis::sequence::FastaOutputIterator::FastaOutputIterator
FastaOutputIterator(std::shared_ptr< utils::BaseOutputTarget > target)
Definition: fasta_output_iterator.hpp:82
genesis::sequence::FastaOutputIterator::self_type
FastaOutputIterator self_type
Definition: fasta_output_iterator.hpp:74
genesis::sequence::Sequence
Definition: sequence/sequence.hpp:40
genesis::sequence::FastaWriter
Write Fasta data.
Definition: fasta_writer.hpp:67
genesis::sequence::FastaOutputIterator::operator<<
self_type & operator<<(Sequence const &seq)
Definition: fasta_output_iterator.hpp:104
fasta_writer.hpp
genesis::sequence::FastaOutputIterator::operator=
self_type & operator=(self_type const &)=default
genesis::sequence::FastaOutputIterator::FastaOutputIterator
FastaOutputIterator(std::shared_ptr< utils::BaseOutputTarget > target, FastaWriter const &writer)
Definition: fasta_output_iterator.hpp:87
genesis::sequence::FastaWriter::write
void write(Sequence const &sequence, std::shared_ptr< utils::BaseOutputTarget > target) const
Write a single Sequence to an output target, using the Fasta format.
Definition: fasta_writer.cpp:50
genesis::sequence::FastaOutputIterator
Write Fasta data, sequentially.
Definition: fasta_output_iterator.hpp:66
genesis
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
Definition: placement/formats/edge_color.cpp:42
output_target.hpp
sequence.hpp