A library for working with phylogenetic and population genetic data.
v0.27.0
FastaWriter Class Reference

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

Detailed Description

Write Fasta data.

This class provides simple facilities for writing Fasta data.

Exemplary usage:

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

FastaWriter().line_length( 100 ).write( sequence_set, utils::to_file( outfile ));

See FastaReader for a description of the Fasta format.

Definition at line 67 of file fasta_writer.hpp.

Public Member Functions

 FastaWriter ()=default
 
 FastaWriter (FastaWriter &&)=default
 
 FastaWriter (FastaWriter const &)=default
 
 ~FastaWriter ()=default
 
AbundanceNotation abundance_notation () const
 Get the current setting for how to write abundances. More...
 
FastaWriterabundance_notation (AbundanceNotation value)
 Set the notation for how to write Sequence abundances. More...
 
size_t line_length () const
 Get the current line length. 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...
 
FastaWriteroperator= (FastaWriter &&)=default
 
FastaWriteroperator= (FastaWriter const &)=default
 
void write (Sequence const &sequence, std::shared_ptr< utils::BaseOutputTarget > target) const
 Write a single Sequence to an output target, using the Fasta format. More...
 
void write (SequenceSet const &sequence_set, std::shared_ptr< utils::BaseOutputTarget > target) const
 Write a SequenceSet to an output target, using the Fasta format. More...
 
void write_sequence (Sequence const &sequence, 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() [1/3]

FastaWriter ( )
default

◆ ~FastaWriter()

~FastaWriter ( )
default

◆ FastaWriter() [2/3]

FastaWriter ( FastaWriter const &  )
default

◆ FastaWriter() [3/3]

FastaWriter ( FastaWriter &&  )
default

Member Function Documentation

◆ abundance_notation() [1/2]

FastaWriter::AbundanceNotation abundance_notation ( ) const

Get the current setting for how to write abundances.

Definition at line 119 of file fasta_writer.cpp.

◆ abundance_notation() [2/2]

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 113 of file fasta_writer.cpp.

◆ line_length() [1/2]

size_t line_length ( ) const

Get the current line length.

See the setter line_length( size_t ) for details.

Definition at line 108 of file fasta_writer.cpp.

◆ line_length() [2/2]

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 102 of file fasta_writer.cpp.

◆ operator=() [1/2]

FastaWriter& operator= ( FastaWriter &&  )
default

◆ operator=() [2/2]

FastaWriter& operator= ( FastaWriter const &  )
default

◆ write() [1/2]

void write ( Sequence const &  sequence,
std::shared_ptr< utils::BaseOutputTarget target 
) const

Write a single Sequence to an output target, using the Fasta format.

See the output target convenience functions utils::to_file(), utils::to_stream(), and utils::to_string() for examples of how to obtain a suitable output target.

Definition at line 50 of file fasta_writer.cpp.

◆ write() [2/2]

void write ( SequenceSet const &  sequence_set,
std::shared_ptr< utils::BaseOutputTarget target 
) const

Write a SequenceSet to an output target, using the Fasta format.

See the output target convenience functions utils::to_file(), utils::to_stream(), and utils::to_string() for examples of how to obtain a suitable output target.

Definition at line 55 of file fasta_writer.cpp.

◆ write_sequence()

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

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

Definition at line 63 of file fasta_writer.cpp.

Member Enumeration Documentation

◆ AbundanceNotation

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 78 of file fasta_writer.hpp.


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