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

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

Detailed Description

Iterate an input stream and parse it as Fasta sequences.

This class allows to iterate over an input stream, iterpreting it as Fasta sequences, and yielding one such sequence per iteration step. This is useful for processing large files without having to keep them fully in memory.

Example:

auto it = FastaInputIterator();
it.from_file( "/path/to/large_file.fasta" );
while( it ) {
    std::cout << it->length() << "\n";
    ++it;
}

See FastaReader for a description of the expected format. In order to change the reading behaviour, use the reader() function to access the internal FastaReaser and change its properties.

The copy constructur copies a pointer the the underlying stream. Thus, when advancing the copy to the next Sequence, the original "skips" this Sequence, as the stream then is at the next one.

Thread safety: No thread safety. The common use case for this iterator is to loop over a file. Thus, guarding induces unnecessary overhead. If multiple threads read from this iterator, both dereferencing and incrementing need to be guarded.

Definition at line 79 of file fasta_input_iterator.hpp.

Public Member Functions

 FastaInputIterator ()
 Create a default instance, using a default FastaReader. More...
 
 FastaInputIterator (FastaReader const &reader)
 Create an instance that copies the settings of a given FastaReader. More...
 
 FastaInputIterator (self_type const &)=default
 
 FastaInputIterator (self_type &&)=default
 
 ~FastaInputIterator ()=default
 
value_type const & dereference () const
 
self_typefrom_file (std::string const &file_name)
 Start reading from an input string. More...
 
self_typefrom_stream (std::istream &input_stream)
 Start reading from an input stream. More...
 
self_typefrom_string (std::string const &input_string)
 Start reading from an input file. More...
 
void increment ()
 
 operator bool () const
 Return true iff dereferencing is valid, i.e., iff there is a Sequence available. More...
 
bool operator!= (self_type const &other) const
 
value_type const & operator* () const
 
self_typeoperator++ ()
 
value_type const * operator-> () const
 
self_typeoperator= (self_type const &)=default
 
self_typeoperator= (self_type &&)=default
 
bool operator== (self_type const &other) const
 
FastaReaderreader ()
 Return the FastaReader used for this iterator. More...
 

Public Types

using difference_type = std::ptrdiff_t
 
using iterator_category = std::input_iterator_tag
 
using pointer = value_type &
 
using reference = value_type *
 
using self_type = FastaInputIterator
 
using value_type = Sequence
 

Constructor & Destructor Documentation

FastaInputIterator ( )
inline

Create a default instance, using a default FastaReader.

Definition at line 101 of file fasta_input_iterator.hpp.

FastaInputIterator ( FastaReader const &  reader)
inline

Create an instance that copies the settings of a given FastaReader.

Definition at line 109 of file fasta_input_iterator.hpp.

~FastaInputIterator ( )
default
FastaInputIterator ( self_type const &  )
default
FastaInputIterator ( self_type &&  )
default

Member Function Documentation

value_type const& dereference ( ) const
inline

Definition at line 207 of file fasta_input_iterator.hpp.

self_type& from_file ( std::string const &  file_name)
inline

Start reading from an input string.

This reads the first Sequence so that it is available for dereferencing.

Definition at line 146 of file fasta_input_iterator.hpp.

self_type& from_stream ( std::istream &  input_stream)
inline

Start reading from an input stream.

This reads the first Sequence so that it is available for dereferencing.

Definition at line 131 of file fasta_input_iterator.hpp.

self_type& from_string ( std::string const &  input_string)
inline

Start reading from an input file.

This reads the first Sequence so that it is available for dereferencing.

Definition at line 161 of file fasta_input_iterator.hpp.

void increment ( )
inline

Definition at line 232 of file fasta_input_iterator.hpp.

operator bool ( ) const
inlineexplicit

Return true iff dereferencing is valid, i.e., iff there is a Sequence available.

Definition at line 188 of file fasta_input_iterator.hpp.

bool operator!= ( self_type const &  other) const
inline

Definition at line 180 of file fasta_input_iterator.hpp.

value_type const& operator* ( ) const
inline

Definition at line 197 of file fasta_input_iterator.hpp.

self_type& operator++ ( )
inline

Definition at line 226 of file fasta_input_iterator.hpp.

value_type const* operator-> ( ) const
inline

Definition at line 202 of file fasta_input_iterator.hpp.

self_type& operator= ( self_type const &  )
default
self_type& operator= ( self_type &&  )
default
bool operator== ( self_type const &  other) const
inline

Definition at line 175 of file fasta_input_iterator.hpp.

FastaReader& reader ( )
inline

Return the FastaReader used for this iterator.

Use this to change the reading behaviour of the iterator. See FastaReader for details.

Definition at line 217 of file fasta_input_iterator.hpp.

Member Typedef Documentation

using difference_type = std::ptrdiff_t

Definition at line 91 of file fasta_input_iterator.hpp.

using iterator_category = std::input_iterator_tag

Definition at line 92 of file fasta_input_iterator.hpp.

using pointer = value_type&

Definition at line 89 of file fasta_input_iterator.hpp.

Definition at line 90 of file fasta_input_iterator.hpp.

Definition at line 87 of file fasta_input_iterator.hpp.

Definition at line 88 of file fasta_input_iterator.hpp.


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