A toolkit for working with phylogenetic data.
v0.24.0
jplace_writer.hpp
Go to the documentation of this file.
1 #ifndef GENESIS_PLACEMENT_FORMATS_JPLACE_WRITER_H_
2 #define GENESIS_PLACEMENT_FORMATS_JPLACE_WRITER_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 
35 
36 #include <iosfwd>
37 #include <string>
38 #include <vector>
39 
40 namespace genesis {
41 
42 // =================================================================================================
43 // Forward Declarations
44 // =================================================================================================
45 
46 namespace utils {
47  class JsonDocument;
48 }
49 
50 namespace placement {
51  class Sample;
52  class SampleSet;
53 }
54 
55 // =================================================================================================
56 // Jplace Writer
57 // =================================================================================================
58 
59 namespace placement {
60 
81 {
82 public:
83 
84  // ---------------------------------------------------------------------
85  // Constructor and Rule of Five
86  // ---------------------------------------------------------------------
87 
88  JplaceWriter();
89  ~JplaceWriter() = default;
90 
91  JplaceWriter( JplaceWriter const& ) = default;
92  JplaceWriter( JplaceWriter&& ) = default;
93 
94  JplaceWriter& operator= ( JplaceWriter const& ) = default;
95  JplaceWriter& operator= ( JplaceWriter&& ) = default;
96 
97  // ---------------------------------------------------------------------
98  // Printing
99  // ---------------------------------------------------------------------
100 
107  void write( Sample const& sample, std::shared_ptr<utils::BaseOutputTarget> target ) const;
108 
116  utils::JsonDocument to_document( Sample const& sample ) const;
117 
118  // -------------------------------------------------------------------------
119  // Settings
120  // -------------------------------------------------------------------------
121 
122 public:
123 
128  size_t branch_length_precision() const
129  {
130  return branch_length_precision_;
131  }
132 
138  {
139  branch_length_precision_ = value;
140  return *this;
141  }
142 
149  std::string const& program() const
150  {
151  return program_;
152  }
153 
159  JplaceWriter& program( std::string const& program )
160  {
161  program_ = program;
162  return *this;
163  }
164 
171  std::string const& invocation() const
172  {
173  return invocation_;
174  }
175 
181  JplaceWriter& invocation( std::string const& invocation )
182  {
183  invocation_ = invocation;
184  return *this;
185  }
186 
187 private:
188 
189  size_t branch_length_precision_ = 6;
190  std::string program_;
191  std::string invocation_;
192 };
193 
194 } // namespace placement
195 } // namespace genesis
196 
197 #endif // include guard
JplaceWriter & invocation(std::string const &invocation)
Set the "invocation" string to be written to the jplace file.
std::string const & program() const
Get the currently set "program" string to be written to the jplace file.
Container namespace for all symbols of genesis in order to keep them separate when used as a library...
JplaceWriter & branch_length_precision(size_t value)
Set the precision used for printing the branch_length floating point numbers of the reference Tree of...
Store a Json value of any kind.
Manage a set of Pqueries along with the PlacementTree where the PqueryPlacements are placed on...
Definition: sample.hpp:68
JplaceWriter & program(std::string const &program)
Set the "program" string to be written to the jplace file.
std::string const & invocation() const
Get the currently set "invocation" string to be written to the jplace file.
size_t branch_length_precision() const
Get the precision used for printing the branch_length floating point numbers of the reference Tree of...