A toolkit for working with phylogenetic data.
v0.20.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JplaceWriter Class Reference

#include <genesis/placement/formats/jplace_writer.hpp>

Detailed Description

Write Jplace data.

This class provides facilities for writing Jplace data. It supports to write

Exemplary usage:

std::string outfile = "path/to/file.jplace";
Sample sample;

JplaceWriter()
    .to_file( sample, outfile );

See JplaceReader for more information on the data format. See Sample for more information on the data structure.

Definition at line 80 of file jplace_writer.hpp.

Public Member Functions

size_t branch_length_precision () const
 Get the precision used for printing the branch_length floating point numbers of the reference Tree of the Sample. More...
 
JplaceWriterbranch_length_precision (size_t value)
 Set the precision used for printing the branch_length floating point numbers of the reference Tree of the Sample. More...
 
void to_document (Sample const &smp, utils::JsonDocument &doc) const
 Store the data of a Sample in a JsonDocument object. More...
 
void to_file (Sample const &smp, std::string const &filename) const
 Write the data of a Sample to a file in Jplace format. More...
 
void to_stream (Sample const &smp, std::ostream &os) const
 Write a Sample to a stream, using the Jplace format. More...
 
void to_string (Sample const &smp, std::string &output) const
 Store the data of a Sample in a string in Jplace format. More...
 
std::string to_string (Sample const &smp) const
 Return the data of a Sample as a string in Jplace format. More...
 

Member Function Documentation

size_t branch_length_precision ( ) const
inline

Get the precision used for printing the branch_length floating point numbers of the reference Tree of the Sample.

Definition at line 106 of file jplace_writer.hpp.

JplaceWriter& branch_length_precision ( size_t  value)
inline

Set the precision used for printing the branch_length floating point numbers of the reference Tree of the Sample.

Definition at line 115 of file jplace_writer.hpp.

void to_document ( Sample const &  smp,
utils::JsonDocument doc 
) const

Store the data of a Sample in a JsonDocument object.

This method is not really useful anymore, as we can now directly write to files, strings and streams. It is however kept here for reference and in case someone wants to work with Json files directly.

Definition at line 216 of file jplace_writer.cpp.

void to_file ( Sample const &  sample,
std::string const &  filename 
) const

Write the data of a Sample to a file in Jplace format.

If the file cannot be written to, the function throws an exception. Also, by default, if the file already exists, an exception is thrown. See Options::allow_file_overwriting() to change this behaviour.

Definition at line 182 of file jplace_writer.cpp.

void to_stream ( Sample const &  smp,
std::ostream &  os 
) const

Write a Sample to a stream, using the Jplace format.

Definition at line 66 of file jplace_writer.cpp.

void to_string ( Sample const &  smp,
std::string &  output 
) const

Store the data of a Sample in a string in Jplace format.

Definition at line 192 of file jplace_writer.cpp.

std::string to_string ( Sample const &  smp) const

Return the data of a Sample as a string in Jplace format.

Definition at line 202 of file jplace_writer.cpp.


The documentation for this class was generated from the following files: