A toolkit for working with phylogenetic data.
v0.18.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
 
FastaWriterenable_metadata (bool value)
 Set whether metadata is written. More...
 
bool enable_metadata ()
 Return whether currently the FastaWriter is set to write metadata. 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...
 

Constructor & Destructor Documentation

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

Member Function Documentation

FastaWriter & enable_metadata ( bool  value)

Set whether metadata is written.

If set to true (default), the metadata of the Sequences is written after the label, separated by a space. This is also the format that FastaReader can read.

The functions returns the FastaWriter object to allow fluent interfaces.

Definition at line 108 of file fasta_writer.cpp.

bool enable_metadata ( )

Return whether currently the FastaWriter is set to write metadata.

See the setter enable_metadata( bool ) for details.

Definition at line 114 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 97 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 103 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 79 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 72 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 86 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 49 of file fasta_writer.cpp.


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