A toolkit for working with phylogenetic data.
v0.20.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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-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 #include <vector>
37 
38 namespace genesis {
39 
40 // =================================================================================================
41 // Forward Declarations
42 // =================================================================================================
43 
44 namespace utils {
45  class JsonDocument;
46 }
47 
48 namespace placement {
49  class Sample;
50  class SampleSet;
51 }
52 
53 // =================================================================================================
54 // Jplace Writer
55 // =================================================================================================
56 
57 namespace placement {
58 
81 {
82 public:
83 
84  // ---------------------------------------------------------------------
85  // Printing
86  // ---------------------------------------------------------------------
87 
88  void to_stream ( Sample const& smp, std::ostream& os ) const;
89  void to_file ( Sample const& smp, std::string const& filename) const;
90 
91  void to_string ( Sample const& smp, std::string& output) const;
92  std::string to_string ( Sample const& smp) const;
93 
94  void to_document ( Sample const& smp, utils::JsonDocument& doc) const;
95 
96  // -------------------------------------------------------------------------
97  // Data Members
98  // -------------------------------------------------------------------------
99 
100 public:
101 
106  size_t branch_length_precision() const
107  {
108  return branch_length_precision_;
109  }
110 
116  {
117  branch_length_precision_ = value;
118  return *this;
119  }
120 
121 private:
122 
123  int branch_length_precision_ = 6;
124 };
125 
126 } // namespace placement
127 } // namespace genesis
128 
129 #endif // include guard
void to_document(Sample const &smp, utils::JsonDocument &doc) const
Store the data of a Sample in a JsonDocument object.
size_t branch_length_precision() const
Get the precision used for printing the branch_length floating point numbers of the reference Tree of...
void to_file(Sample const &smp, std::string const &filename) const
Write the data of a Sample to a file in Jplace format.
JplaceWriter & branch_length_precision(size_t value)
Set the precision used for printing the branch_length floating point numbers of the reference Tree of...
void to_string(Sample const &smp, std::string &output) const
Store the data of a Sample in a string in Jplace format.
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
void to_stream(Sample const &smp, std::ostream &os) const
Write a Sample to a stream, using the Jplace format.