1 #ifndef GENESIS_TREE_FORMATS_NEWICK_WRITER_H_ 2 #define GENESIS_TREE_FORMATS_NEWICK_WRITER_H_ 54 struct NewickBrokerElement;
174 void write(
Tree const& tree, std::shared_ptr<utils::BaseOutputTarget> target )
const;
187 void write(
TreeSet const&
tree_set, std::shared_ptr<utils::BaseOutputTarget> target,
bool with_names =
false )
const;
258 quotation_mark_ = value;
269 return quotation_mark_;
282 force_quot_marks_ = value;
293 return force_quot_marks_;
309 line_length_ = value;
335 trailing_new_line_ = value;
347 return trailing_new_line_;
358 write_names_ = value;
380 write_values_ = value;
391 return write_values_;
402 write_comments_ = value;
413 return write_comments_;
451 void write(
NewickBroker const& broker, std::shared_ptr<utils::BaseOutputTarget> target )
const;
475 bool force_quot_marks_ =
false;
476 char quotation_mark_ =
'\"';
477 size_t line_length_ = 0;
478 bool trailing_new_line_ =
true;
480 bool write_names_ =
true;
481 bool write_values_ =
true;
482 bool write_comments_ =
true;
483 bool write_tags_ =
true;
490 #endif // include guard std::vector< finish_writing_function > finish_writing_plugins
Collect all functions to be called after finishing the actual tree writing.
bool force_quotation_marks() const
Get whether all names are wrapped in quotation marks.
NewickWriter & quotation_mark(char value)
Set the type of quotation marks used for node names that contain special characters.
std::function< void(Tree const &tree, NewickBroker &broker) > finish_writing_function
Function type that allows to do some finalizing work with the Tree and NewickBroker after the actual ...
Write a Tree to Newick format.
std::vector< node_to_element_function > node_to_element_plugins
Collect all functions to be called for each TreeNode in order to translate it to a Newick representat...
bool write_tags() const
Get whether Newick tags (e.g., for jplace files) are written.
NewickWriter & line_length(size_t value)
Set the approximate maximal line length to use when writing Newick trees.
std::function< void(Tree const &tree, NewickBroker &broker) > prepare_writing_function
Function type that allows to do some preparatory work with the Tree and NewickBroker before the actua...
Container namespace for all symbols of genesis in order to keep them separate when used as a library...
size_t line_length() const
Get the currently set approximate maximal line length.
NewickWriter & write_tags(bool value)
Set whether to write Newick tags (e.g., for jplace files).
std::string to_string(Tree const &tree) const
Shorthand to write a Tree to Newick format and return it is a string.
std::function< void(TreeEdge const &edge, NewickBrokerElement &element) > edge_to_element_function
Function type that translates from a TreeEdge to a NewickBrokerElement.
virtual ~NewickWriter()=default
tree::TreeSet tree_set(SampleSet const &sample_set)
Return a TreeSet containing all the trees of the SampleSet.
Stores a Newick tree in an intermediate format that can be further processed into a Tree...
NewickWriter & write_names(bool value)
Set whether to write Newick node names.
std::function< void(TreeNode const &node, NewickBrokerElement &element) > node_to_element_function
Function type that translates from a TreeNode to a NewickBrokerElement.
NewickWriter & write_comments(bool value)
Set whether to write Newick comments (e.g., some forms of bootstrap values).
Class for representing phylogenetic trees.
void write(Tree const &tree, std::shared_ptr< utils::BaseOutputTarget > target) const
Write a Tree to an output target, using the Newick format.
NewickWriter & force_quotation_marks(bool value)
If set to true, all names are wrapped in quotation marks, regardless of whether the name contains any...
bool write_comments() const
Get whether Newick comments (e.g., some forms of bootstrap values) are written.
std::vector< prepare_writing_function > prepare_writing_plugins
Collect all functions to be called before starting the actual tree writing.
NewickBroker tree_to_broker(Tree const &tree) const
Transform the information of the tree into a NewickBroker object.
bool write_values() const
Get whether Newick values (e.g., branch lengths) are written.
NewickWriter & operator=(NewickWriter const &)=default
bool trailing_new_line() const
Get the current setting for whether a new line char \n is written to the end of each tree...
NewickWriter & trailing_new_line(bool value)
Set whether to write a new line char \n at the end of each tree.
std::vector< edge_to_element_function > edge_to_element_plugins
Collect all functions to be called for each TreeEdge in order to translate it to a Newick representat...
bool write_names() const
Get whether Newick node names are written.
NewickWriter & write_values(bool value)
Set whether to write Newick values (e.g., branch lengths).
Store the information for one element of a Newick tree.
char quotation_mark() const
Get the currently set type of quotation marks used for node names.