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

#include <genesis/sequence/printers/simple.hpp>

Detailed Description

Simple printer class for Sequences and SequenceSets.

It provides to print() Sequences to strings and ostreams.

By default, no colors are set, thus, Sequences are printed without color. You have to set the color_map() first, for example using the colors defined in nucleic_acid_text_colors() or amino_acid_text_colors().

Definition at line 61 of file simple.hpp.

Public Member Functions

 PrinterSimple ()=default
 
 PrinterSimple (PrinterSimple const &)=default
 
 PrinterSimple (PrinterSimple &&)=default
 
 ~PrinterSimple ()=default
 
PrinterSimplecolor_map (std::map< char, std::string > const &value)
 Set the list of colors to use for the Sequence charaters. More...
 
std::map< char, std::string >
const & 
color_map () const
 Get the currently set list of colors for each Sequence character. More...
 
PrinterSimplecolor_mode (ColorMode value)
 Set whether to use color in the background, foreground, or not at all. More...
 
ColorMode color_mode () const
 Get the currently set color mode. More...
 
PrinterSimplelabel_mode (LabelMode value)
 Set the currently set LabelMode. More...
 
LabelMode label_mode () const
 Get the currently set LabelMode. More...
 
PrinterSimplelength_limit (size_t value)
 Set the length limit for printing Sequences. More...
 
size_t length_limit () const
 Get the currently set length limit. More...
 
PrinterSimpleline_length (size_t value)
 Set the length of each line, i.e., when to wrap. More...
 
size_t line_length () const
 Get the currently set line length, i.e., when to wrap. More...
 
std::string operator() (Sequence const &seq) const
 Return a string representing the print of a single Sequence. More...
 
std::string operator() (SequenceSet const &set) const
 Return a string representing the print of a SequenceSet. More...
 
PrinterSimpleoperator= (PrinterSimple const &)=default
 
PrinterSimpleoperator= (PrinterSimple &&)=default
 
void print (std::ostream &out, Sequence const &seq) const
 Print a single Sequence to a stream. More...
 
void print (std::ostream &out, SequenceSet const &set) const
 Print a SequenceSet to a stream. More...
 
std::string print (Sequence const &seq) const
 Return a string representing the print of a single Sequence. More...
 
std::string print (SequenceSet const &set) const
 Return a string representing the print of a SequenceSet. More...
 
PrinterSimplesequence_limit (size_t value)
 Set the limit for how many Sequences to print. More...
 
size_t sequence_limit () const
 Get the currently set limit for how many Sequences to print. More...
 

Public Types

enum  ColorMode { kNone, kForeground, kBackground }
 Modes for how the Sequence sites are colored. More...
 
enum  LabelMode { kNone, kSameLine, kSeparateLine }
 Modes for how to print Sequence labels. More...
 

Constructor & Destructor Documentation

PrinterSimple ( )
default
~PrinterSimple ( )
default
PrinterSimple ( PrinterSimple const &  )
default
PrinterSimple ( PrinterSimple &&  )
default

Member Function Documentation

PrinterSimple & color_map ( std::map< char, std::string > const &  value)

Set the list of colors to use for the Sequence charaters.

The provided map sets the color name for each Sequence character. The presettings nucleic_acid_text_colors() and amino_acid_text_colors() for default sequence types can be used as input for this parameter. If the colors map does not contain a key for one of the chars in the sequence, the char is printed without color.

See color_mode() for more details. See utils::Style for details and for a list of the available color names.

Definition at line 150 of file simple.cpp.

std::map< char, std::string > const & color_map ( ) const

Get the currently set list of colors for each Sequence character.

See the setter for details.

Definition at line 156 of file simple.cpp.

PrinterSimple & color_mode ( PrinterSimple::ColorMode  value)

Set whether to use color in the background, foreground, or not at all.

See ColorMode for details.

Definition at line 161 of file simple.cpp.

PrinterSimple::ColorMode color_mode ( ) const

Get the currently set color mode.

See the setter for details.

Definition at line 167 of file simple.cpp.

PrinterSimple & label_mode ( PrinterSimple::LabelMode  value)

Set the currently set LabelMode.

See LabelMode for more information.

Definition at line 172 of file simple.cpp.

PrinterSimple::LabelMode label_mode ( ) const

Get the currently set LabelMode.

See the setter and LabelMode for more information.

Definition at line 178 of file simple.cpp.

PrinterSimple & length_limit ( size_t  value)

Set the length limit for printing Sequences.

This parameter limits the output length to the give number of chars. If set to 0, the whole Sequence is printed (default). If the limit is lower than the acutal number of sites in the Sequence, ellipsis " ..." are appended.

Definition at line 139 of file simple.cpp.

size_t length_limit ( ) const

Get the currently set length limit.

See the setter for details.

Definition at line 145 of file simple.cpp.

PrinterSimple & line_length ( size_t  value)

Set the length of each line, i.e., when to wrap.

If this parameter is set to a value other than 0, the Sequence is wrapped at this line length. This also works in combination with length_limit().

Definition at line 128 of file simple.cpp.

size_t line_length ( ) const

Get the currently set line length, i.e., when to wrap.

See the setter for details.

Definition at line 134 of file simple.cpp.

std::string operator() ( Sequence const &  seq) const

Return a string representing the print of a single Sequence.

This is simply an alias for print();

Definition at line 101 of file simple.cpp.

std::string operator() ( SequenceSet const &  set) const

Return a string representing the print of a SequenceSet.

This is simply an alias for print();

Definition at line 107 of file simple.cpp.

PrinterSimple& operator= ( PrinterSimple const &  )
default
PrinterSimple& operator= ( PrinterSimple &&  )
default
void print ( std::ostream &  out,
Sequence const &  seq 
) const

Print a single Sequence to a stream.

Definition at line 49 of file simple.cpp.

void print ( std::ostream &  out,
SequenceSet const &  set 
) const

Print a SequenceSet to a stream.

Definition at line 56 of file simple.cpp.

std::string print ( Sequence const &  seq) const

Return a string representing the print of a single Sequence.

Definition at line 85 of file simple.cpp.

std::string print ( SequenceSet const &  set) const

Return a string representing the print of a SequenceSet.

Definition at line 93 of file simple.cpp.

PrinterSimple & sequence_limit ( size_t  value)

Set the limit for how many Sequences to print.

If this parameter is set to a value other than 0, only this number of Sequences are printed. Default is 0, thus, all Sequences are printed. If the given limit is lower than the acutal number of Sequences in the SequenceSet, ellipsis " ..." are appended.

Definition at line 117 of file simple.cpp.

size_t sequence_limit ( ) const

Get the currently set limit for how many Sequences to print.

See the setter for details.

Definition at line 123 of file simple.cpp.

Member Enumeration Documentation

enum ColorMode
strong

Modes for how the Sequence sites are colored.

In order for the coloring to work, a map from site characters to the name of the color needs to be provided via color_map(). See there for details.

The coloring is applied using escape sequences. This works on most modern terminals. See utils::Style for details and for a list of the available color names.

Enumerator
kNone 

No color, even if a color_map() is provided.

kForeground 

Color the text foreground of the characters, leave the background at default.

kBackground 

Color the text background of the characters, set the foreground to black.

Definition at line 78 of file simple.hpp.

enum LabelMode
strong

Modes for how to print Sequence labels.

Enumerator
kNone 

No label is printed.

kSameLine 

The label is printed on the line where the Sequence sites start, separated from them by ": ".

kSeparateLine 

The label is printed on a line preceeding the Sequence sites.

Definition at line 98 of file simple.hpp.


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