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

#include <genesis/sequence/formats/fasta_writer.hpp>

Detailed Description

Write Fasta data.

This class provides simple facilities for writing Fasta data. It supports to write

Exemplary usage:

std::string outfile = "path/to/file.fasta";
SequenceSet sset;

FastaWriter()
    .line_length( 100 )
    .to_file( sset, outfile );

See FastaReader for a description of the Fasta format.

Definition at line 71 of file fasta_writer.hpp.

Public Member Functions

 FastaWriter ()=default
 
 FastaWriter (FastaWriter const &)=default
 
 FastaWriter (FastaWriter &&)=default
 
 ~FastaWriter ()=default
 
FastaWriterabundance_notation (AbundanceNotation value)
 Set the notation for how to write Sequence abundances. More...
 
AbundanceNotation abundance_notation () const
 Get the current setting for how to write abundances. More...
 
FastaWriterline_length (size_t value)
 Set the line length, which determines after how many chars (Sequence sites) lines breaks are inserted when writing the Fasta file. More...
 
size_t line_length () const
 Get the current line length. More...
 
FastaWriteroperator= (FastaWriter const &)=default
 
FastaWriteroperator= (FastaWriter &&)=default
 
void to_file (SequenceSet const &sset, std::string const &fn) const
 Write Sequences of a SequenceSet to a file, using the Fasta format. More...
 
void to_stream (SequenceSet const &sset, std::ostream &os) const
 Write Sequences of a SequenceSet to a stream, using the Fasta format. More...
 
std::string to_string (SequenceSet const &sset) const
 Return Sequences of a SequenceSet in form of a Fasta formatted string. More...
 
void write_sequence (Sequence const &seq, std::ostream &os) const
 Write a single Sequence to an output stream in Fasta format. More...
 

Public Types

enum  AbundanceNotation { kNone, kUnderscore, kSize }
 Enumeration of types for how to write Sequence abundances. More...
 

Constructor & Destructor Documentation

FastaWriter ( )
default
~FastaWriter ( )
default
FastaWriter ( FastaWriter const &  )
default
FastaWriter ( FastaWriter &&  )
default

Member Function Documentation

FastaWriter & abundance_notation ( FastaWriter::AbundanceNotation  value)

Set the notation for how to write Sequence abundances.

Default is to not write abundances. Use this setting to change that.

Definition at line 121 of file fasta_writer.cpp.

FastaWriter::AbundanceNotation abundance_notation ( ) const

Get the current setting for how to write abundances.

Definition at line 127 of file fasta_writer.cpp.

FastaWriter & line_length ( size_t  value)

Set the line length, which determines after how many chars (Sequence sites) lines breaks are inserted when writing the Fasta file.

Default is 80. If set to 0, no breaks are inserted. The functions returns the FastaWriter object to allow fluent interfaces.

Definition at line 110 of file fasta_writer.cpp.

size_t line_length ( ) const

Get the current line length.

See the setter line_length( size_t ) for details.

Definition at line 116 of file fasta_writer.cpp.

FastaWriter& operator= ( FastaWriter const &  )
default
FastaWriter& operator= ( FastaWriter &&  )
default
void to_file ( SequenceSet const &  sset,
std::string const &  fn 
) const

Write Sequences of a SequenceSet to a file, using the Fasta format.

If the file cannot be written to, the function throws an exception. Also, by default, if the file already exists, an exception is thrown. See Options::allow_file_overwriting() to change this behaviour.

Definition at line 92 of file fasta_writer.cpp.

void to_stream ( SequenceSet const &  sset,
std::ostream &  os 
) const

Write Sequences of a SequenceSet to a stream, using the Fasta format.

Definition at line 85 of file fasta_writer.cpp.

std::string to_string ( SequenceSet const &  sset) const

Return Sequences of a SequenceSet in form of a Fasta formatted string.

Caveat: This might be a long string! If you simply want to examine a Sequence or SequenceSet, have a look at the print() and print_color() functions.

Definition at line 99 of file fasta_writer.cpp.

void write_sequence ( Sequence const &  seq,
std::ostream &  os 
) const

Write a single Sequence to an output stream in Fasta format.

Definition at line 50 of file fasta_writer.cpp.

Member Enumeration Documentation

enum AbundanceNotation
strong

Enumeration of types for how to write Sequence abundances.

Enumerator
kNone 

Do not write abundances. This is the default.

kUnderscore 

Write abundances appaneded by an underscore: abc_123.

kSize 

Write abundances appended as a text of the form abc;size=123

Definition at line 82 of file fasta_writer.hpp.


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