A toolkit for working with phylogenetic data.
v0.24.0
JplaceWriter Class Reference

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

Detailed Description

Write Jplace data.

This class provides facilities for writing Jplace data to different output targets.

Exemplary usage:

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

JplaceWriter().write( sample, utils::to_file( outfile ));

Furthermore, using to_document(), the Sample can also be transformed into our internal Json representaion in form of a utils::JsonDocument that adheres to the Jplace standard. This is probably rarely needed, but might be useful nonetheless.

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

 JplaceWriter ()
 
 JplaceWriter (JplaceWriter const &)=default
 
 JplaceWriter (JplaceWriter &&)=default
 
 ~JplaceWriter ()=default
 
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...
 
std::string const & invocation () const
 Get the currently set "invocation" string to be written to the jplace file. More...
 
JplaceWriterinvocation (std::string const &invocation)
 Set the "invocation" string to be written to the jplace file. More...
 
JplaceWriteroperator= (JplaceWriter const &)=default
 
JplaceWriteroperator= (JplaceWriter &&)=default
 
std::string const & program () const
 Get the currently set "program" string to be written to the jplace file. More...
 
JplaceWriterprogram (std::string const &program)
 Set the "program" string to be written to the jplace file. More...
 
utils::JsonDocument to_document (Sample const &sample) const
 Store the data of a Sample in a JsonDocument object. More...
 
void write (Sample const &sample, std::shared_ptr< utils::BaseOutputTarget > target) const
 Write a Sample to an output target, using the Jplace format. More...
 

Constructor & Destructor Documentation

◆ JplaceWriter() [1/3]

Definition at line 65 of file jplace_writer.cpp.

◆ ~JplaceWriter()

~JplaceWriter ( )
default

◆ JplaceWriter() [2/3]

JplaceWriter ( JplaceWriter const &  )
default

◆ JplaceWriter() [3/3]

JplaceWriter ( JplaceWriter &&  )
default

Member Function Documentation

◆ branch_length_precision() [1/2]

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 128 of file jplace_writer.hpp.

◆ branch_length_precision() [2/2]

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 137 of file jplace_writer.hpp.

◆ invocation() [1/2]

std::string const& invocation ( ) const
inline

Get the currently set "invocation" string to be written to the jplace file.

This is jplace meta-data that can be set to later identify settings used when creating the jplace file.

Definition at line 171 of file jplace_writer.hpp.

◆ invocation() [2/2]

JplaceWriter& invocation ( std::string const &  invocation)
inline

Set the "invocation" string to be written to the jplace file.

Get the currently set "invocation" string to be written to the jplace file. This is jplace meta-data that can be set to later identify settings used when creating the jplace file.

Definition at line 181 of file jplace_writer.hpp.

◆ operator=() [1/2]

JplaceWriter& operator= ( JplaceWriter const &  )
default

◆ operator=() [2/2]

JplaceWriter& operator= ( JplaceWriter &&  )
default

◆ program() [1/2]

std::string const& program ( ) const
inline

Get the currently set "program" string to be written to the jplace file.

This is jplace meta-data that can be set to later identify settings used when creating the jplace file.

Definition at line 149 of file jplace_writer.hpp.

◆ program() [2/2]

JplaceWriter& program ( std::string const &  program)
inline

Set the "program" string to be written to the jplace file.

Get the currently set "program" string to be written to the jplace file. This is jplace meta-data that can be set to later identify settings used when creating the jplace file.

Definition at line 159 of file jplace_writer.hpp.

◆ to_document()

utils::JsonDocument to_document ( Sample const &  sample) 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 190 of file jplace_writer.cpp.

◆ write()

void write ( Sample const &  sample,
std::shared_ptr< utils::BaseOutputTarget target 
) const

Write a Sample to an output target, using the Jplace format.

See the output target convenience functions utils::to_file(), utils::to_stream(), and utils::to_string() for examples of how to obtain a suitable output target.

Definition at line 75 of file jplace_writer.cpp.


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