A library for working with phylogenetic and population genetic data.
v0.27.0
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 &&)=default
 
 PrinterSimple (PrinterSimple const &)=default
 
 ~PrinterSimple ()=default
 
std::map< char, std::string > const & color_map () const
 Get the currently set list of colors for each Sequence character. More...
 
PrinterSimplecolor_map (std::map< char, std::string > const &value)
 Set the list of colors to use for the Sequence charaters. More...
 
ColorMode color_mode () const
 Get the currently set color mode. More...
 
PrinterSimplecolor_mode (ColorMode value)
 Set whether to use color in the background, foreground, or not at all. More...
 
LabelMode label_mode () const
 Get the currently set LabelMode. More...
 
PrinterSimplelabel_mode (LabelMode value)
 Set the currently set LabelMode. More...
 
size_t length_limit () const
 Get the currently set length limit. More...
 
PrinterSimplelength_limit (size_t value)
 Set the length limit for printing Sequences. More...
 
size_t line_length () const
 Get the currently set line length, i.e., when to wrap. More...
 
PrinterSimpleline_length (size_t value)
 Set the length of each line, 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 &&)=default
 
PrinterSimpleoperator= (PrinterSimple const &)=default
 
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...
 
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...
 
size_t sequence_limit () const
 Get the currently set limit for how many Sequences to print. More...
 
PrinterSimplesequence_limit (size_t value)
 Set the 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() [1/3]

PrinterSimple ( )
default

◆ ~PrinterSimple()

~PrinterSimple ( )
default

◆ PrinterSimple() [2/3]

PrinterSimple ( PrinterSimple const &  )
default

◆ PrinterSimple() [3/3]

PrinterSimple ( PrinterSimple &&  )
default

Member Function Documentation

◆ color_map() [1/2]

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.

◆ color_map() [2/2]

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.

◆ color_mode() [1/2]

PrinterSimple::ColorMode color_mode ( ) const

Get the currently set color mode.

See the setter for details.

Definition at line 167 of file simple.cpp.

◆ color_mode() [2/2]

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.

◆ label_mode() [1/2]

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.

◆ label_mode() [2/2]

PrinterSimple & label_mode ( PrinterSimple::LabelMode  value)

Set the currently set LabelMode.

See LabelMode for more information.

Definition at line 172 of file simple.cpp.

◆ length_limit() [1/2]

size_t length_limit ( ) const

Get the currently set length limit.

See the setter for details.

Definition at line 145 of file simple.cpp.

◆ length_limit() [2/2]

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.

◆ line_length() [1/2]

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.

◆ line_length() [2/2]

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.

◆ operator()() [1/2]

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.

◆ operator()() [2/2]

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.

◆ operator=() [1/2]

PrinterSimple& operator= ( PrinterSimple &&  )
default

◆ operator=() [2/2]

PrinterSimple& operator= ( PrinterSimple const &  )
default

◆ print() [1/4]

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.

◆ print() [2/4]

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

Return a string representing the print of a SequenceSet.

Definition at line 93 of file simple.cpp.

◆ print() [3/4]

void print ( std::ostream &  out,
Sequence const &  seq 
) const

Print a single Sequence to a stream.

Definition at line 49 of file simple.cpp.

◆ print() [4/4]

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

Print a SequenceSet to a stream.

Definition at line 56 of file simple.cpp.

◆ sequence_limit() [1/2]

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.

◆ sequence_limit() [2/2]

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.

Member Enumeration Documentation

◆ ColorMode

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.

◆ LabelMode

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: