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

#include <genesis/tree/printer/compact.hpp>

Detailed Description

Print a Tree in a compact form, i.e., each node and edge on one line.

For example, given the Newick tree

(((A:0.2,B:0.3)C:0.3,(D:0.4,E:0.45,F:0.3,G:0.35)H:0.25)I:0.8,J:0.4,K:0.5)L;

and using the print( Tree const& ) function for DefaultTrees, the output is

L: 0.8
├── I: 0.8
│   ├── C: 0.3
│   │   ├── A: 0.2
│   │   └── B: 0.3
│   └── H: 0.25
│       ├── D: 0.4
│       ├── E: 0.45
│       ├── F: 0.3
│       └── G: 0.35
├── J: 0.4
└── K: 0.5

Using the print() functions with function parameters, it is also possible to print custom data for each node and edge.

Definition at line 82 of file compact.hpp.

Public Member Functions

 PrinterCompact ()=default
 Default constructor. More...
 
 PrinterCompact (PrinterCompact const &)=default
 Default copy constructor. More...
 
 PrinterCompact (PrinterCompact &&)=default
 Default move constructor. More...
 
 ~PrinterCompact ()=default
 Default destructor. More...
 
PrinterCompactoperator= (PrinterCompact const &)=default
 Deault copy assignment. More...
 
PrinterCompactoperator= (PrinterCompact &&)=default
 Default move assignment. More...
 
void print (std::ostream &out, Tree const &tree, std::function< std::string(TreeNode const &node, TreeEdge const &edge)> const print_line)
 Print a compact representation of a Tree to an output stream, using a given function for output of the Node and Edge data. More...
 
std::string print (Tree const &tree, std::function< std::string(TreeNode const &node, TreeEdge const &edge)> const print_line)
 Print a compact representation of a Tree to a std::string, using a given function for output of the Node and Edge data. More...
 
std::string print (Tree const &tree)
 Print a compact representation of a Tree to a std::string, for DefaultTrees. More...
 

Constructor & Destructor Documentation

PrinterCompact ( )
default

Default constructor.

~PrinterCompact ( )
default

Default destructor.

PrinterCompact ( PrinterCompact const &  )
default

Default copy constructor.

PrinterCompact ( PrinterCompact &&  )
default

Default move constructor.

Member Function Documentation

PrinterCompact& operator= ( PrinterCompact const &  )
default

Deault copy assignment.

PrinterCompact& operator= ( PrinterCompact &&  )
default

Default move assignment.

void print ( std::ostream &  out,
Tree const &  tree,
std::function< std::string(TreeNode const &node, TreeEdge const &edge)> const  print_line 
)

Print a compact representation of a Tree to an output stream, using a given function for output of the Node and Edge data.

The print_line function parameter is used to customize the output per printed line: The function takes the current TreeNode and TreeEdge, and returns the desired string representation for that line. See the implementation of print( Tree const& ) for an example.

Definition at line 49 of file compact.cpp.

std::string print ( Tree const &  tree,
std::function< std::string(TreeNode const &node, TreeEdge const &edge)> const  print_line 
)

Print a compact representation of a Tree to a std::string, using a given function for output of the Node and Edge data.

See print() for details on the print_line function parameter.

Definition at line 120 of file compact.cpp.

std::string print ( Tree const &  tree)

Print a compact representation of a Tree to a std::string, for DefaultTrees.

The function casts the node and edge data to DefaultNodeData and DefaultEdgeData, and, if successfull, prints the node name and branch length for each line.

If the data is not actually default data, the nodes are printed without any text, i.e., only the topology of the Tree via lines is shown.

Definition at line 132 of file compact.cpp.


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