|
A library for working with phylogenetic and population genetic data.
v0.32.0
|
|
Go to the documentation of this file. 1 #ifndef GENESIS_TREE_COMMON_TREE_NEWICK_WRITER_H_
2 #define GENESIS_TREE_COMMON_TREE_NEWICK_WRITER_H_
83 return default_leaf_name_;
91 default_leaf_name_ = value;
100 return default_inner_name_;
108 default_inner_name_ = value;
117 return default_root_name_;
125 default_root_name_ = value;
135 default_leaf_name_ = value;
136 default_inner_name_ = value;
137 default_root_name_ = value;
148 return use_default_names_;
175 use_default_names_ = value;
187 return replace_invalid_chars_;
209 replace_invalid_chars_ = value;
220 enable_names_ = value;
229 return enable_names_;
237 enable_branch_lengths_ = value;
246 return enable_branch_lengths_;
255 return branch_length_precision_;
266 branch_length_precision_ = value;
280 if( replace_invalid_chars_ ) {
281 static const std::string invalids(
" :;()[],={}\"" );
282 for(
auto& c : name ) {
283 if( invalids.find(c) != std::string::npos ) {
291 if( use_default_names_ && (
292 (
is_leaf( node ) && name == default_leaf_name_ ) ||
293 (
is_inner( node ) && name == default_inner_name_ ) ||
294 (
is_root( node ) && name == default_root_name_ )
305 if (enable_branch_lengths_) {
335 int branch_length_precision_ = 6;
337 std::string default_leaf_name_ =
"Leaf_Node";
338 std::string default_inner_name_ =
"Inner_Node";
339 std::string default_root_name_ =
"Root_Node";
341 bool use_default_names_ =
false;
342 bool replace_invalid_chars_ =
true;
344 bool enable_names_ =
true;
345 bool enable_branch_lengths_ =
true;
386 #endif // include guard
virtual ~CommonTreeNewickWriterPlugin()=default
self_type & default_leaf_name(std::string const &value)
Set the named used to filter out a leaf node name.
self_type & enable_branch_lengths(bool value)
Set whether to write branch lengths.
std::string name
Name of the node.
Write a Tree to Newick format.
bool enable_branch_lengths() const
Get whether currently any branch lengths are written.
bool is_inner(TreeLink const &link)
Return true iff the node of the given link is an inner node.
std::string to_string_rounded(double const value, int const precision)
Return a string representation of the input value, using the provided precision value (determining it...
std::string const & default_root_name() const
Get the named used to filter out the root node name.
int branch_length_precision() const
Get the currently set maximum precision (in number of digits) used for printing the branch_length flo...
Write default Newick trees, i.e., trees with names and branch lengths.
void node_to_element(TreeNode const &node, NewickBrokerElement &element) const
self_type & set_default_names(std::string const &value)
Shorthand to set the default names for leaf, inner and root node at once, to one value.
Provides some valuable additions to STD.
bool replace_invalid_chars() const
Return whether currently this plugin replaces characters that are invalid in the Newick file format w...
std::vector< std::string > values
Numerical values associated with the node, i.e. branch lengths.
Provides some commonly used string utility functions.
self_type & replace_invalid_chars(bool value)
Set whether to replace all characters that are invalid in the Newick file format in names with unders...
bool is_root(TreeLink const &link)
Return whether the link belongs to the root node of its Tree.
std::string const & default_leaf_name() const
Get the named used to filter out a leaf node name.
self_type & use_default_names(bool value)
Set whether to replace default named nodes with an empty string.
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...
self_type & branch_length_precision(int value)
Set the maximum precision (in number of digits) used for printing the branch_length floating point nu...
void edge_to_element(TreeEdge const &edge, NewickBrokerElement &element) const
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
self_type & default_inner_name(std::string const &value)
Set the named used to filter out an inner node name.
bool use_default_names() const
Return whether currently default names are activated in this plugin.
self_type & enable_names(bool value)
Set whether to write node names at all.
Provide a set of plugin functions for NewickWriter to write a CommonTree.
Common class containing the commonly needed data for tree edges.
void register_with(NewickWriter &writer) const
Common class containing the commonly needed data for tree nodes.
std::string const & default_inner_name() const
Get the named used to filter out an inner node name.
bool enable_names() const
Get whether currently any node names are written at all.
bool is_leaf(TreeLink const &link)
Return true iff the node of the given link is a leaf node.
Store the information for one element of a Newick tree.
self_type & default_root_name(std::string const &value)
Set the named used to filter out the root node name.
CommonTreeNewickWriterPlugin & operator=(CommonTreeNewickWriterPlugin const &)=default
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...
CommonTreeNewickWriterPlugin()=default