A toolkit for working with phylogenetic data.
v0.18.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-2017 Lucas Czech
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 <string>
35 #include <vector>
36 
37 namespace genesis {
38 
39 // =================================================================================================
40 // Forward Declarations
41 // =================================================================================================
42 
43 namespace utils {
44  class JsonDocument;
45 }
46 
47 namespace placement {
48  class Sample;
49  class SampleSet;
50 }
51 
52 // =================================================================================================
53 // Jplace Writer
54 // =================================================================================================
55 
56 namespace placement {
57 
80 {
81 public:
82 
83  // ---------------------------------------------------------------------
84  // Printing
85  // ---------------------------------------------------------------------
86 
87  void to_stream ( Sample const& smp, std::ostream& os ) const;
88  void to_file ( Sample const& smp, std::string const& filename) const;
89 
90  void to_string ( Sample const& smp, std::string& output) const;
91  std::string to_string ( Sample const& smp) const;
92 
93  void to_document ( Sample const& smp, utils::JsonDocument& doc) const;
94 
95  // -------------------------------------------------------------------------
96  // Data Members
97  // -------------------------------------------------------------------------
98 
99 public:
100 
105  size_t branch_length_precision() const
106  {
107  return branch_length_precision_;
108  }
109 
115  {
116  branch_length_precision_ = value;
117  return *this;
118  }
119 
120 private:
121 
122  int branch_length_precision_ = 6;
123 };
124 
125 } // namespace placement
126 } // namespace genesis
127 
128 #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.