A toolkit for working with phylogenetic data.
v0.20.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
fasta_writer.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_SEQUENCE_FORMATS_FASTA_WRITER_H_
2 #define GENESIS_SEQUENCE_FORMATS_FASTA_WRITER_H_
3 
4 /*
5  Genesis - A toolkit for working with phylogenetic data.
6  Copyright (C) 2014-2018 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 
34 #include <iosfwd>
35 #include <string>
36 
37 namespace genesis {
38 namespace sequence {
39 
40 // =================================================================================================
41 // Forward Declarations
42 // =================================================================================================
43 
44 class Sequence;
45 class SequenceSet;
46 
47 // =================================================================================================
48 // Fasta Writer
49 // =================================================================================================
50 
72 {
73 public:
74 
75  // ---------------------------------------------------------------------
76  // Typedefs and Enums
77  // ---------------------------------------------------------------------
78 
82  enum class AbundanceNotation
83  {
87  kNone,
88 
93 
97  kSize
98  };
99 
100  // ---------------------------------------------------------------------
101  // Constructor and Rule of Five
102  // ---------------------------------------------------------------------
103 
104  FastaWriter() = default;
105  ~FastaWriter() = default;
106 
107  FastaWriter( FastaWriter const& ) = default;
108  FastaWriter( FastaWriter&& ) = default;
109 
110  FastaWriter& operator= ( FastaWriter const& ) = default;
111  FastaWriter& operator= ( FastaWriter&& ) = default;
112 
113  // ---------------------------------------------------------------------
114  // Writing
115  // ---------------------------------------------------------------------
116 
120  void write_sequence( Sequence const& seq, std::ostream& os ) const;
121 
125  void to_stream ( SequenceSet const& sset, std::ostream& os ) const;
126 
135  void to_file ( SequenceSet const& sset, std::string const& fn ) const;
136 
143  std::string to_string ( SequenceSet const& sset ) const;
144 
145  // ---------------------------------------------------------------------
146  // Properties
147  // ---------------------------------------------------------------------
148 
156  FastaWriter& line_length( size_t value );
157 
163  size_t line_length() const;
164 
171 
176 
177  // ---------------------------------------------------------------------
178  // Members
179  // ---------------------------------------------------------------------
180 
181 private:
182 
183  size_t line_length_ = 80;
184  AbundanceNotation abundance_notation_ = AbundanceNotation::kNone;
185 
186 };
187 
188 } // namespace sequence
189 } // namespace genesis
190 
191 #endif // include guard
AbundanceNotation
Enumeration of types for how to write Sequence abundances.
void to_stream(SequenceSet const &sset, std::ostream &os) const
Write Sequences of a SequenceSet to a stream, using the Fasta format.
void to_file(SequenceSet const &sset, std::string const &fn) const
Write Sequences of a SequenceSet to a file, using the Fasta format.
Write abundances appended as a text of the form abc;size=123
size_t line_length() const
Get the current line length.
FastaWriter & operator=(FastaWriter const &)=default
Write abundances appaneded by an underscore: abc_123.
Do not write abundances. This is the default.
Store a set of Sequences.
void write_sequence(Sequence const &seq, std::ostream &os) const
Write a single Sequence to an output stream in Fasta format.
AbundanceNotation abundance_notation() const
Get the current setting for how to write abundances.
std::string to_string(SequenceSet const &sset) const
Return Sequences of a SequenceSet in form of a Fasta formatted string.